org.infinispan.hotrod.telemetry.impl.TelemetryServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-hotrod-jakarta Show documentation
Show all versions of infinispan-hotrod-jakarta Show documentation
Infinispan Hot Rod Client Jakarta EE
package org.infinispan.hotrod.telemetry.impl;
import java.nio.charset.StandardCharsets;
import org.infinispan.hotrod.impl.protocol.HeaderParams;
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator;
import io.opentelemetry.context.Context;
public class TelemetryServiceImpl implements TelemetryService {
private final W3CTraceContextPropagator propagator;
public TelemetryServiceImpl() {
propagator = W3CTraceContextPropagator.getInstance();
}
public void injectSpanContext(HeaderParams header) {
// Inject the request with the *current* Context, which contains client current Span if exists.
propagator.inject(Context.current(), header,
(carrier, paramKey, paramValue) ->
carrier.otherParam(paramKey, paramValue.getBytes(StandardCharsets.UTF_8))
);
}
}