-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from saytoshivam/main
telemetry sdk name changed to lm-opentelemetry
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
otel-resource/src/main/java/com/logicmonitor/resource/detectors/common/LMCommonResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.logicmonitor.resource.detectors.common; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.common.AttributesBuilder; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; | ||
|
||
public class LMCommonResource { | ||
private static final Resource INSTANCE = buildResource(); | ||
|
||
public static Resource get() { | ||
return INSTANCE; | ||
} | ||
|
||
static Resource buildResource() { | ||
AttributesBuilder attrBuilders = Attributes.builder(); | ||
attrBuilders.put(ResourceAttributes.TELEMETRY_SDK_NAME, "lm-opentelemetry"); | ||
|
||
return Resource.create(attrBuilders.build(), ResourceAttributes.SCHEMA_URL); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ce/src/main/java/com/logicmonitor/resource/detectors/common/LMCommonResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.logicmonitor.resource.detectors.common; | ||
|
||
// import com.logicmonitor.resource.detectors.aws.ec2.LMEc2Resource; | ||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
|
||
public class LMCommonResourceProvider implements ResourceProvider { | ||
@Override | ||
public Resource createResource(ConfigProperties config) { | ||
return LMCommonResource.get(); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
.../main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
com.logicmonitor.resource.detectors.aws.ec2.LMEc2ResourceProvider | ||
com.logicmonitor.resource.detectors.aws.ec2.LMEc2ResourceProvider | ||
com.logicmonitor.resource.detectors.common.LMCommonResourceProvider |
20 changes: 20 additions & 0 deletions
20
...rc/test/java/com/logicmonitor/resource/detectors/common/LMCommonResourceProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.logicmonitor.resource.detectors.common; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.common.AttributesBuilder; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class LMCommonResourceProviderTest { | ||
@Test | ||
public void whenProvidedValidCommonResourceThenReturnResourceWithTelemetrySDKName() { | ||
AttributesBuilder attrBuilders = Attributes.builder(); | ||
attrBuilders.put(ResourceAttributes.TELEMETRY_SDK_NAME, "lm-opentelemetry"); | ||
Resource resources = Resource.create(attrBuilders.build(), ResourceAttributes.SCHEMA_URL); | ||
Resource lmResource = LMCommonResource.buildResource(); | ||
assertEquals(resources, lmResource); | ||
} | ||
} |