Skip to content

Commit

Permalink
Merge pull request #8 from saytoshivam/main
Browse files Browse the repository at this point in the history
telemetry sdk name changed to lm-opentelemetry
  • Loading branch information
Gaurang-Patel authored Mar 9, 2022
2 parents fdeb04b + 96ffeb3 commit a77bdb9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
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);
}
}
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();
}
}
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
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);
}
}

0 comments on commit a77bdb9

Please sign in to comment.