You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The script reports two transactions to sentry: one with opentelemetry sdk, and another one with sentry sdk.
My expectations are that the transactions' trace context would be similar, however the opentelemetry-created transaction does not have a status set.
importjsonimportsentry_sdkfromopentelemetryimporttracefromopentelemetry.sdk.traceimportTracerProviderfromopentelemetry.propagateimportset_global_textmapfromopentelemetry.sdk.trace.exportimportConsoleSpanExporter, SimpleSpanProcessorfromopentelemetry.traceimportStatus, StatusCodefromsentry_sdk.integrations.opentelemetryimportSentryPropagator, SentrySpanProcessortracer=trace.get_tracer("main")
classConsoleTransport(sentry_sdk.Transport):
""" A sentry transport that stores events in memory and sends them to stdout instead of sending them to Sentry """def__init__(self):
super().__init__()
self.transactions= []
defcapture_envelope(self, envelope):
foriteminenvelope.items:
ifitem.data_category!="transaction":
continuetransaction=item.get_transaction_event()
print("captured transaction:")
print(json.dumps(transaction, indent=4))
self.transactions.append(item.get_transaction_event())
deffind_transaction(self, name):
fortransactioninself.transactions:
iftransaction.get("transaction") ==name:
returntransactiondefconfigure_sentry(transport):
sentry_sdk.init(
# fake dsn to enable tracingdsn="https://[email protected]/1",
traces_sample_rate=1.0,
transport=transport,
instrumenter="otel",
)
defconfigure_opentelemetry():
provider=TracerProvider()
# Sentry integrationprovider.add_span_processor(SentrySpanProcessor())
set_global_textmap(SentryPropagator())
# Console exporter to verify that the otel span has an error statusexporter=ConsoleSpanExporter(
formatter=lambdaspan: f"opentelemetry span:\n{span.to_json()}\n"
)
processor=SimpleSpanProcessor(exporter)
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
defcreate_otel_transaction():
""" Capture an example transaction with opentelemetry sdk :return: """withtracer.start_as_current_span(name="otel_transaction") asspan:
try:
raiseValueError("from otel transaction")
exceptValueErrorasexc:
span.record_exception(exc)
span.set_status(Status(StatusCode.ERROR))
# At this point I expect that sentry's transaction# would also have an error statusdefcreate_sentry_transaction():
""" Capture an example transaction with sentry sdk """withsentry_sdk.start_transaction(
name="sentry_transaction", instrumenter="otel"
) astransaction:
try:
raiseValueError("from sentry transaction")
exceptValueError:
transaction.set_status("unknown_error")
defmain():
sentry_transport=ConsoleTransport()
configure_sentry(sentry_transport)
configure_opentelemetry()
create_otel_transaction()
create_sentry_transaction()
otel_transaction=sentry_transport.find_transaction("otel_transaction")
sentry_transaction=sentry_transport.find_transaction("sentry_transaction")
sentry_transaction_status=sentry_transaction["contexts"]["trace"].get("status")
otel_transaction_status=otel_transaction["contexts"]["trace"].get("status")
print(f"Sentry-created transaction status: {sentry_transaction_status}")
print(f"Otel-created transaction status: {otel_transaction_status}")
if__name__=="__main__":
main()
Expected Result
Sentry's Opentelemetry integration propagates the span status to the Sentry transaction trace context, and Sentry classifies the transaction as an error in the user interface.
Actual Result
The transaction created from an opentelemetry span does not have a status set.
How do you use Sentry?
Self-hosted/on-premise
Version
1.22.2
Steps to Reproduce
I use the Opentelemetry integration to send my Opentelemetry spans to Sentry. My code is manually instrumented with the opentelemetry sdk.
I noticed that if an otel span has an error status, the status is not propagated to Sentry's transaction/span trace context.
Below is a script that demonstrates the issue. It needs the following requirements to work:
The script reports two transactions to sentry: one with opentelemetry sdk, and another one with sentry sdk.
My expectations are that the transactions' trace context would be similar, however the opentelemetry-created transaction does not have a status set.
Expected Result
Sentry's Opentelemetry integration propagates the span status to the Sentry transaction trace context, and Sentry classifies the transaction as an error in the user interface.
Actual Result
The transaction created from an opentelemetry span does not have a status set.
Example script output:
The text was updated successfully, but these errors were encountered: