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
Describe the bug
Unable to set a specific traceId to the start span when using the OpenTelemetry API in Dart
Steps to reproduce
1.Initialize the OpenTelemetry SDK and configure it with the necessary exporters.
2.Create a new span and attempt to set a specific traceId.
3.Start the span.
4.Observe the traceId of the started span in jeager
import 'package:opentelemetry/api.dart' as otel;
import 'package:opentelemetry/sdk.dart' as otel_sdk;
otel.Tracer? globalTracer;
void setupTracing() async {
final resource = otel_sdk.Resource(
[otel.Attribute.fromString('service.name', 'myproject')]);
final exporter = otel_sdk.CollectorExporter(
Uri.parse('Jeager URL'),
);
final processor = otel_sdk.BatchSpanProcessor(exporter);
final provider =
otel_sdk.TracerProviderBase(processors: [processor], resource: resource);
registerGlobalTracerProvider(provider);
globalTracer = provider.getTracer('myproject');
}
import 'package:opentelemetry/api.dart' as otel;
String? traceId = "8888bf2278369600d98ef29b6b628455";
String spanId =
"0000000000000001";
final spanContext = otel.SpanContext(
otel.TraceId.fromString(traceId),
otel.SpanId.fromString(spanId),
otel.TraceFlags.sampled,
otel.TraceState.empty(),
);
final spanKey = otel.ContextKey();
final newContext = otel.Context.current.setValue(spanKey, spanContext);
final span = globalTracer?.startSpan(
'fetchPolicyInfo',
context: newContext,
kind: otel.SpanKind.client,
);
What did you expect to see?
The span should start with the traceId set to the specific value provided
What did you see instead?
The span starts with a different traceId generated by the SDK, ignoring the provided traceId.
What version and what artifacts are you using?
Artifacts: opentelemetry
Version: v0.18.2
opentelemetry: ^0.18.2
Environment
Dart Version: 3.4.1
OS: Windows 11
The text was updated successfully, but these errors were encountered:
The ContextKey you are using to set a value in the Context isn't the same key that tracer.startSpan() looks for when setting the span's parent. You will want to use contextWithSpanContext(context, spanContext).
Describe the bug
Unable to set a specific traceId to the start span when using the OpenTelemetry API in Dart
Steps to reproduce
1.Initialize the OpenTelemetry SDK and configure it with the necessary exporters.
2.Create a new span and attempt to set a specific traceId.
3.Start the span.
4.Observe the traceId of the started span in jeager
import 'package:opentelemetry/api.dart' as otel;
import 'package:opentelemetry/sdk.dart' as otel_sdk;
otel.Tracer? globalTracer;
void setupTracing() async {
final resource = otel_sdk.Resource(
[otel.Attribute.fromString('service.name', 'myproject')]);
final exporter = otel_sdk.CollectorExporter(
Uri.parse('Jeager URL'),
);
final processor = otel_sdk.BatchSpanProcessor(exporter);
final provider =
otel_sdk.TracerProviderBase(processors: [processor], resource: resource);
registerGlobalTracerProvider(provider);
globalTracer = provider.getTracer('myproject');
}
import 'package:opentelemetry/api.dart' as otel;
String? traceId = "8888bf2278369600d98ef29b6b628455";
String spanId =
"0000000000000001";
final spanContext = otel.SpanContext(
otel.TraceId.fromString(traceId),
otel.SpanId.fromString(spanId),
otel.TraceFlags.sampled,
otel.TraceState.empty(),
);
final spanKey = otel.ContextKey();
final newContext = otel.Context.current.setValue(spanKey, spanContext);
final span = globalTracer?.startSpan(
'fetchPolicyInfo',
context: newContext,
kind: otel.SpanKind.client,
);
What did you expect to see?
The span should start with the traceId set to the specific value provided
What did you see instead?
The span starts with a different traceId generated by the SDK, ignoring the provided traceId.
What version and what artifacts are you using?
Artifacts: opentelemetry
Version: v0.18.2
opentelemetry: ^0.18.2
Environment
Dart Version: 3.4.1
OS: Windows 11
The text was updated successfully, but these errors were encountered: