All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.client.hotrod.telemetry.impl.TelemetryOperation Maven / Gradle / Ivy

package org.infinispan.client.hotrod.telemetry.impl;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

import org.infinispan.client.hotrod.impl.operations.DelegatingHotRodOperation;
import org.infinispan.client.hotrod.impl.operations.HotRodOperation;

import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator;
import io.opentelemetry.context.Context;

public class TelemetryOperation extends DelegatingHotRodOperation {
   private final Context context;

   protected TelemetryOperation(HotRodOperation delegate) {
      super(delegate);
      // This relies upon the fact that this created in the invoking user thread
      this.context = Context.current();
   }

   @Override
   public Map additionalParameters() {
      Map mapToUse = super.additionalParameters();
      if (mapToUse == null) {
         mapToUse = new HashMap<>();
      }
      W3CTraceContextPropagator.getInstance()
            .inject(context, mapToUse,
            (carrier, paramKey, paramValue) ->
                  carrier.put(paramKey, paramValue.getBytes(StandardCharsets.UTF_8)));
      return mapToUse;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy