Skip to content

[paymentservice] error.type attribute missing on server spans during payment failures #3758

Description

@bhuvan-somisetty

Description

When an error occurs during payment processing in the Payment Service (for example, when the paymentFailure feature flag is enabled or when invalid payment credentials are provided), the Payment Service correctly sets the span status to ERROR. However, it does not set the error.type attribute on the span.

According to the OpenTelemetry Semantic Conventions for Exceptions and Errors, whenever an operation fails or span status is ERROR, an error.type attribute SHOULD be recorded on the span to allow backend metrics exporters and observability platforms to aggregate and categorize errors cleanly.


Service Interaction & Data Flow

┌─────────────────┐       gRPC ChargeRequest       ┌─────────────────┐
│                 │ ─────────────────────────────> │                 │
│ CheckoutService │                                │ PaymentService  │
│                 │ <───────────────────────────── │    (Node.js)    │
└─────────────────┘      gRPC Error / Exception    └─────────────────┘
                                                            │
                                                            ▼
                                                   Span Status: ERROR
                                                  [Missing error.type!]

Current vs Expected Telemetry

Attribute Name Current Behavior Expected Behavior
span.status_code ERROR ERROR
status.message "Payment failed" "Payment failed"
error.type (Not Present) "PaymentFailureError" / "InvalidArgument"
rpc.service "oteldemo.PaymentService" "oteldemo.PaymentService"
rpc.method "Charge" "Charge"

Impact

Without the error.type attribute:

  1. Metrics Aggregation: Error rate metrics (such as span metrics processors or OTel collector connector metrics) cannot group error counts by error classification.
  2. Dashboard Visualizations: Grafana and Jaeger trace charts cannot filter traces by specific failure categories.
  3. Spec Alignment: The service falls out of alignment with current OpenTelemetry Semantic Conventions.

Steps to Reproduce

  1. Start the OpenTelemetry Demo application stack.
  2. Enable the paymentFailure feature flag in flagd (or set it to 100%).
  3. Place an order through the store UI or send a ChargeRequest to the Payment Service.
  4. Inspect the generated span for oteldemo.PaymentService/Charge in Jaeger / Grafana / OTLP exporter logs.
  5. Observe that the span status is set to ERROR, but no error.type attribute is attached.

Proposed Fix Plan

In the Payment Service charge handler (src/paymentservice/charge.js), when an error occurs during payment processing:

  1. Set error.type on the active span using the error class name or code (e.g., span.setAttribute('error.type', err.name || 'PaymentFailureError')).
  2. Ensure exception recording is properly associated with the span.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions