|
19 | 19 | import com.google.auto.service.AutoService; |
20 | 20 | import io.opentelemetry.api.common.Attributes; |
21 | 21 | import io.opentelemetry.api.common.AttributesBuilder; |
22 | | -import io.opentelemetry.sdk.resources.ResourceAttributes; |
23 | | -import io.opentelemetry.sdk.resources.ResourceProvider; |
| 22 | +import io.opentelemetry.sdk.autoconfigure.ConfigProperties; |
| 23 | +import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; |
| 24 | +import io.opentelemetry.sdk.resources.Resource; |
| 25 | +import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; |
24 | 26 | import org.hypertrace.agent.config.Config.AgentConfig; |
25 | 27 | import org.hypertrace.agent.core.config.HypertraceConfig; |
26 | 28 |
|
27 | 29 | @AutoService(ResourceProvider.class) |
28 | | -public class HypertraceResourceProvider extends ResourceProvider { |
| 30 | +public class HypertraceResourceProvider implements ResourceProvider { |
29 | 31 |
|
30 | 32 | private final CgroupsReader cgroupsReader = new CgroupsReader(); |
31 | 33 | private final AgentConfig agentConfig = HypertraceConfig.get(); |
32 | 34 |
|
33 | 35 | @Override |
34 | | - protected Attributes getAttributes() { |
| 36 | + public Resource createResource(ConfigProperties config) { |
35 | 37 | AttributesBuilder builder = Attributes.builder(); |
36 | 38 | String containerId = this.cgroupsReader.readContainerId(); |
37 | 39 | if (containerId != null && !containerId.isEmpty()) { |
38 | 40 | builder.put(ResourceAttributes.CONTAINER_ID, containerId); |
39 | 41 | } |
40 | 42 | builder.put(ResourceAttributes.SERVICE_NAME, agentConfig.getServiceName().getValue()); |
41 | | - return builder.build(); |
| 43 | + return Resource.create(builder.build()); |
42 | 44 | } |
43 | 45 | } |
0 commit comments