Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
NipunaMadhushan committed Dec 7, 2023
1 parent 49d1c96 commit f197b50
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
*/
public class NewRelicTracerProvider implements TracerProvider {
private static final String TRACER_NAME = "newrelic";
private static final String CONST_SAMPLER_TYPE = "const";
private static final String PROBABILISTIC_SAMPLER_TYPE = "probabilistic";
private static final String TRACE_REPORTER_ENDPOINT = "https://otlp.nr-data.net:4317";
private static final String TRACE_API_KEY_HEADER = "Api-Key";

Expand Down Expand Up @@ -88,13 +90,13 @@ public static BArray startPublishingTraces(BString apiKey, BString samplerType,
private static Sampler selectSampler(BString samplerType, BDecimal samplerParam) {
switch (samplerType.getValue()) {
default:
case "const":
case CONST_SAMPLER_TYPE:
if (samplerParam.value().intValue() == 0) {
return Sampler.alwaysOff();
} else {
return Sampler.alwaysOn();
}
case "probabilistic":
case PROBABILISTIC_SAMPLER_TYPE:
return Sampler.traceIdRatioBased(samplerParam.value().doubleValue());
case RateLimitingSampler.TYPE:
return new RateLimitingSampler(samplerParam.value().intValue());
Expand All @@ -106,7 +108,7 @@ public Tracer getTracer(String serviceName) {

return tracerProviderBuilder.setResource(
Resource.create(Attributes.of(SERVICE_NAME, serviceName)))
.build().get("newrelic");
.build().get(TRACER_NAME);
}

@Override
Expand Down

0 comments on commit f197b50

Please sign in to comment.