Skip to content

Commit

Permalink
Capture http method in operation name (#1679)
Browse files Browse the repository at this point in the history
* Capture http method in operation name

* Bump version

* Update change log
  • Loading branch information
trask authored May 11, 2021
1 parent c465635 commit 18d6981
Show file tree
Hide file tree
Showing 27 changed files with 16 additions and 57 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# CHANGELOG
# Version 3.1.0
* Capture http method in the operation name [#1679](https://github.com/microsoft/ApplicationInsights-Java/pull/1679)

# Version 3.0.4-BETA.2
* Enable users to override iKey, cloud role name and cloud role instance per telemetry [#1630](https://github.com/microsoft/ApplicationInsights-Java/pull/1630).
* Fix duplicate headers [#1640](https://github.com/microsoft/ApplicationInsights-Java/pull/1640).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void configure(SdkTracerProviderBuilder tracerProvider) {

if (currExporter == null) {
currExporter = processorConfig.type == ProcessorType.attribute ?
new ExporterWithAttributeProcessor(processorConfig, new Exporter(telemetryClient, config.preview.httpMethodInOperationName)) :
new ExporterWithSpanProcessor(processorConfig, new Exporter(telemetryClient, config.preview.httpMethodInOperationName));
new ExporterWithAttributeProcessor(processorConfig, new Exporter(telemetryClient)) :
new ExporterWithSpanProcessor(processorConfig, new Exporter(telemetryClient));

} else {
currExporter = processorConfig.type == ProcessorType.attribute ?
Expand All @@ -67,7 +67,7 @@ public void configure(SdkTracerProviderBuilder tracerProvider) {
tracerProvider.addSpanProcessor(SimpleSpanProcessor.create(currExporter));

} else {
tracerProvider.addSpanProcessor(SimpleSpanProcessor.create(new Exporter(telemetryClient, config.preview.httpMethodInOperationName)));
tracerProvider.addSpanProcessor(SimpleSpanProcessor.create(new Exporter(telemetryClient)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static class LoggingInstrumentation {
public static class MicrometerInstrumentation {
public boolean enabled = true;
// this is just here to detect if using this old undocumented setting in order to give a helpful error message
@Deprecated
public int reportingIntervalSeconds = 60;
}

Expand Down Expand Up @@ -176,7 +177,8 @@ public static class PreviewConfiguration {
// ignoreRemoteParentNotSampled is currently needed
// because .NET SDK always propagates trace flags "00" (not sampled)
public boolean ignoreRemoteParentNotSampled = true;
// TODO consider turning this on by default in 3.1.0
// this is just here to detect if using this old setting in order to give a helpful message
@Deprecated
public boolean httpMethodInOperationName;
public LiveMetrics liveMetrics = new LiveMetrics();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public static Configuration create(Path agentJarPath, RpConfiguration rpConfigur
" (and note that metricIntervalSeconds applies to all auto-collected metrics," +
" not only micrometer)"));
}
if (config.preview.httpMethodInOperationName) {
configurationWarnMessages.add(new ConfigurationWarnMessage(
"\"httpMethodInOperationName\" preview setting is now the (one and only) default behavior"));
}
overlayEnvVars(config);
applySamplingPercentageRounding(config);
// rp configuration should always be last (so it takes precedence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,8 @@ public class Exporter implements SpanExporter {

private final TelemetryClient telemetryClient;

private final boolean httpMethodInOperationName;

public Exporter(TelemetryClient telemetryClient, boolean httpMethodInOperationName) {
public Exporter(TelemetryClient telemetryClient) {
this.telemetryClient = telemetryClient;
this.httpMethodInOperationName = httpMethodInOperationName;
}

/**
Expand Down Expand Up @@ -623,7 +620,7 @@ private void exportRequest(SpanData span) {

private String getTelemetryName(SpanData span) {
String name = span.getName();
if (!httpMethodInOperationName || !name.startsWith("/")) {
if (!name.startsWith("/")) {
return name;
}
String httpMethod = span.getAttributes().get(SemanticAttributes.HTTP_METHOD);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Project properties
version=3.0.4-BETA.3
version=3.1.0
group=com.microsoft.azure
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://host.docker.internal:6060/",
"preview": {
"httpMethodInOperationName": true,
"instrumentation": {
"azureSdk": {
"enabled": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"test": "value",
"home": "${HOME}",
"service.version": "123"
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://host.docker.internal:6060/",
"preview": {
"httpMethodInOperationName": true,
"customInstrumentation": [
{
"className": "com.microsoft.applicationinsights.smoketestapp.TargetObject",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
"role": {
"name": "testrolename",
"instance": "testroleinstance"
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"cassandra": {
"enabled": false
}
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"jdbc": {
"enabled": false
}
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"jms": {
"enabled": false
}
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"kafka": {
"enabled": false
}
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
}
},
"preview": {
"httpMethodInOperationName": true,
"metricIntervalSeconds": 5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"mongo": {
"enabled": false
}
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"redis": {
"enabled": false
}
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"springScheduling": {
"enabled": false
}
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://host.docker.internal:6060/",
"heartbeat": {
"intervalSeconds": 30
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://host.docker.internal:6060/",
"preview": {
"metricIntervalSeconds": 5
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
"logging": {
"level": "warn"
}
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://host.docker.internal:6060/",
"preview": {
"httpMethodInOperationName": true,
"metricIntervalSeconds": 5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"instance": "testroleinstance"
},
"preview": {
"httpMethodInOperationName": true,
"openTelemetryApiSupport": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://host.docker.internal:6060/",
"sampling": {
"percentage": 50
},
"preview": {
"httpMethodInOperationName": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"percentage": 50
},
"preview": {
"httpMethodInOperationName": true,
"sampling": {
"overrides": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"percentage": 100
},
"preview": {
"httpMethodInOperationName": true,
"sampling": {
"overrides": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://host.docker.internal:6060/",
"preview": {
"httpMethodInOperationName": true,
"processors" : [
{
"type": "attribute",
Expand Down

0 comments on commit 18d6981

Please sign in to comment.