2525import io .opentelemetry .semconv .resource .attributes .ResourceAttributes ;
2626import org .hypertrace .agent .config .Config .AgentConfig ;
2727import org .hypertrace .agent .core .config .HypertraceConfig ;
28+ import org .slf4j .Logger ;
29+ import org .slf4j .LoggerFactory ;
2830
2931@ AutoService (ResourceProvider .class )
3032public class HypertraceResourceProvider implements ResourceProvider {
3133
34+ private static final Logger log =
35+ LoggerFactory .getLogger (HypertraceResourceProvider .class .getName ());
36+
3237 private final CgroupsReader cgroupsReader = new CgroupsReader ();
3338 private final AgentConfig agentConfig = HypertraceConfig .get ();
3439
@@ -40,6 +45,23 @@ public Resource createResource(ConfigProperties config) {
4045 builder .put (ResourceAttributes .CONTAINER_ID , containerId );
4146 }
4247 builder .put (ResourceAttributes .SERVICE_NAME , agentConfig .getServiceName ().getValue ());
48+ builder .put (ResourceAttributes .TELEMETRY_SDK_NAME , "hypertrace" );
49+ builder .put (ResourceAttributes .TELEMETRY_SDK_LANGUAGE , "java" );
50+ String agentVersion = getAgentVersion ();
51+ builder .put (ResourceAttributes .TELEMETRY_SDK_VERSION , agentVersion );
52+ builder .put (ResourceAttributes .TELEMETRY_AUTO_VERSION , agentVersion );
4353 return Resource .create (builder .build ());
4454 }
55+
56+ private String getAgentVersion () {
57+ String agentVersion = "" ;
58+ try {
59+ Class <?> hypertraceAgentClass =
60+ Class .forName ("org.hypertrace.agent.instrument.HypertraceAgent" , true , null );
61+ agentVersion = hypertraceAgentClass .getPackage ().getImplementationVersion ();
62+ } catch (ClassNotFoundException e ) {
63+ log .warn ("Could not load HypertraceAgent class" );
64+ }
65+ return agentVersion ;
66+ }
4567}
0 commit comments