Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the "ERROR" status doesn't show correctly in Google Cloud Trace #303

Closed
multani opened this issue Dec 7, 2023 · 1 comment
Closed

Comments

@multani
Copy link

multani commented Dec 7, 2023

When an error occured and after I set span status to ERROR, the span doesn't show up as error in Google Cloud Trace.

Consider the following example:

#!/usr/bin/env python3

from opentelemetry import trace
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.trace import Status, StatusCode


def setup():
    exporter = CloudTraceSpanExporter()
    # exporter = OTLPSpanExporter(endpoint="127.0.0.1:4317", insecure=True)
    print(f"Using tracing exporter {exporter}")

    processor = BatchSpanProcessor(exporter)

    resource = Resource(attributes={SERVICE_NAME: "test"})
    tracer_provider = TracerProvider(resource=resource)
    tracer_provider.add_span_processor(processor)

    trace.set_tracer_provider(tracer_provider)


def main():
    setup()

    tracer = trace.get_tracer(__name__)
    with tracer.start_as_current_span("first") as span:
        try:
            raise Exception("oh no")
        except Exception as exc:
            span.record_exception(exc)
            span.set_status(Status(StatusCode.ERROR))
            # span.set_attribute("http.status_code", 500)


if __name__ == "__main__":
    main()

It shows up like this in Google Cloud Trace:
Screenshot from 2023-12-07 22-16-01
Screenshot from 2023-12-07 22-16-10

If I switch the exporter from CloudTraceSpanExporter to the OTLPSpanExporter (towards Jaeger), it shows up correctly in Jaeger:

image

Setting the span attribute http.status_code to 500 shows up correctly though, but this doesn't use the "official" status mechanism from OpenTelemetry:

image

@aabmass
Copy link
Collaborator

aabmass commented Jan 29, 2024

@multani this was also reported in GoogleCloudPlatform/opentelemetry-operations-go#730

Unfortunately we can't do anything in the exporter to fix it. Please follow along on that bug.

@aabmass aabmass closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants