Closed wys199703 closed 1 year ago
You could extract trace and span id from the string yourself and set up the context like it is done in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/1a68f4d07d590a54d09aee8f233d8ffa1720ae97/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/LocalRootSpanTest.java#L38-L45 Otel propagators extract from a map. You can put the string you have into a map and in the propagator use the same key. Something like https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/1a68f4d07d590a54d09aee8f233d8ffa1720ae97/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsParentContext.java#L34-L38
@laurit Thanks! I will try and chekc it.
Here is another question about gRPC request.
I brought up this issue as my project write/read trace info to/from request/response header manually. I found opentelemetry instrumentation has a module named 'opentelemetry-grpc-1.6'. Does it has some likely function on grpc request/response inject/extract? And maybe do some customize header.
Our grpc library instrumentation has context propagation support. If this is what your question was.
@laurit Yes, I checked that propagator extracts trace from header 'uber-trace-id'. And does otel-java support to filter which requests with specefied expressions not to be traced? Like skippattern definition in jaegertracing
@wys199703 it is possible to write a sampler for this, for example see https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/samplers/src/main/java/io/opentelemetry/contrib/sampler
Hi @laurit, Maybe there is something misunderstanding about my question. Actually my situation is I do not want to generate a otel context for some specefied http paths like '/actuator/*' but not in the export stage. I've read the code of 'WebMvcTelemetryProducingFilter' and does that can be done in this filter‘s judgement statement 'this.instrumenter.shouldStart(parentContext, request)' by adding the path pattern match judgement?
@wys199703 maybe discussion on https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/7906 is relevant for you?
Hi @trask I checked that issue. Maybe it met my issue. Actually I'm using otel-instrumentation by a otel springboot starter. So I need to replace the default sampler with a self managed 'RuleBasedRoutingSampler'. is that correct?
And another question is I also use otel 'opentelemetry-logback-mdc-1.0' to auto inject trace_id & span_id to my log line. For my understanding is all requests which return true in below judgement 'this.instrumenter.shouldStart(parentContext, request)' will generate trace context in the 'WebMvcTelemetryProducingFilter' and inject the trace info to log line, even through whose trace will not export to the backend. Is that correct?
BTW. I want to confirm does otel can also propagate from a 64 bits trace id by padding zero to the hex high 16~31 like below example ?
SpanContext.createFromRemoteParent( "00000000000000000000000000000001", "0000000000000002", TraceFlags.getSampled(), TraceState.getDefault())))
I want to extract a otel Context/SpanContext from a String format like "trace_id:span_id". In the legacy jaegertracing implementation we can get it form io.jaegertracing.internal.propagation.TextMapCodec.contextFromString(String). So I wonder is there a similar way to do this in opentemeletry-java. I checked opentelemetry-instrumentation-java has four propagators. Seems none to extract from a String.
Is there any way to do this ?
my maven opentelemetry dependencies are :
`