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:
- Metrics Aggregation: Error rate metrics (such as span metrics processors or OTel collector connector metrics) cannot group error counts by error classification.
- Dashboard Visualizations: Grafana and Jaeger trace charts cannot filter traces by specific failure categories.
- Spec Alignment: The service falls out of alignment with current OpenTelemetry Semantic Conventions.
Steps to Reproduce
- Start the OpenTelemetry Demo application stack.
- Enable the
paymentFailure feature flag in flagd (or set it to 100%).
- Place an order through the store UI or send a
ChargeRequest to the Payment Service.
- Inspect the generated span for
oteldemo.PaymentService/Charge in Jaeger / Grafana / OTLP exporter logs.
- 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:
- Set
error.type on the active span using the error class name or code (e.g., span.setAttribute('error.type', err.name || 'PaymentFailureError')).
- Ensure exception recording is properly associated with the span.
Description
When an error occurs during payment processing in the Payment Service (for example, when the
paymentFailurefeature flag is enabled or when invalid payment credentials are provided), the Payment Service correctly sets the span status toERROR. However, it does not set theerror.typeattribute on the span.According to the OpenTelemetry Semantic Conventions for Exceptions and Errors, whenever an operation fails or span status is
ERROR, anerror.typeattribute SHOULD be recorded on the span to allow backend metrics exporters and observability platforms to aggregate and categorize errors cleanly.Service Interaction & Data Flow
Current vs Expected Telemetry
span.status_codeERRORERRORstatus.message"Payment failed""Payment failed"error.type"PaymentFailureError"/"InvalidArgument"rpc.service"oteldemo.PaymentService""oteldemo.PaymentService"rpc.method"Charge""Charge"Impact
Without the
error.typeattribute:Steps to Reproduce
paymentFailurefeature flag inflagd(or set it to 100%).ChargeRequestto the Payment Service.oteldemo.PaymentService/Chargein Jaeger / Grafana / OTLP exporter logs.ERROR, but noerror.typeattribute is attached.Proposed Fix Plan
In the Payment Service charge handler (
src/paymentservice/charge.js), when an error occurs during payment processing:error.typeon the active span using the error class name or code (e.g.,span.setAttribute('error.type', err.name || 'PaymentFailureError')).