fixes jaeger remote sampler service strategies bug (#5418)

This commit is contained in:
DondekarShraddha 2023-05-05 17:53:25 +05:30 committed by GitHub
parent 23c5516252
commit 4af30515a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -17,7 +17,7 @@ public class JaegerRemoteSamplerProvider implements ConfigurableSamplerProvider
static final String ATTRIBUTE_PROPERTY = "otel.resource.attributes";
static final String SERVICE_NAME_PROPERTY = "otel.service.name";
static final String SAMPLER_ARG_PROPERTY = "otel.traces.sampler.arg";
static final String RESOURCE_ATTRIBUTE_SERVICE_NAME_PROPERTY = "service.name";
private static final String ENDPOINT_KEY = "endpoint";
private static final String POLLING_INTERVAL = "pollingInterval";
private static final String INITIAL_SAMPLING_RATE = "initialSamplingRate";
@ -29,7 +29,7 @@ public class JaegerRemoteSamplerProvider implements ConfigurableSamplerProvider
String serviceName = config.getString(SERVICE_NAME_PROPERTY);
if (serviceName == null) {
Map<String, String> resourceAttributes = config.getMap(ATTRIBUTE_PROPERTY);
serviceName = resourceAttributes.get(SERVICE_NAME_PROPERTY);
serviceName = resourceAttributes.get(RESOURCE_ATTRIBUTE_SERVICE_NAME_PROPERTY);
}
if (serviceName != null) {
builder.setServiceName(serviceName);

View File

@ -66,7 +66,8 @@ public class JaegerRemoteSamplerProviderTest {
void serviceNameInAttributeProperties() {
ConfigProperties mockConfig = mock(ConfigProperties.class);
HashMap<String, String> attributeProperties = new HashMap<>();
attributeProperties.put(JaegerRemoteSamplerProvider.SERVICE_NAME_PROPERTY, "test_service2");
attributeProperties.put(
JaegerRemoteSamplerProvider.RESOURCE_ATTRIBUTE_SERVICE_NAME_PROPERTY, "test_service2");
when(mockConfig.getMap(JaegerRemoteSamplerProvider.ATTRIBUTE_PROPERTY))
.thenReturn(attributeProperties);
ServiceLoader<ConfigurableSamplerProvider> samplerProviders =