Skip to content

Commit 0b034de

Browse files
authored
Minor Exporter updates (#2081)
1 parent f0c8498 commit 0b034de

File tree

1 file changed

+10
-13
lines changed
  • agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter

1 file changed

+10
-13
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter/Exporter.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ private void internalExport(SpanData span) {
210210
} else if (instrumentationName.startsWith("io.opentelemetry.spring-scheduling-")
211211
&& !span.getParentSpanContext().isValid()) {
212212
// TODO (trask) AI mapping: need semantic convention for determining whether to map INTERNAL
213-
// to request or
214-
// dependency (or need clarification to use SERVER for this)
213+
// to request or dependency (or need clarification to use SERVER for this)
215214
exportRequest(span);
216215
} else {
217216
exportRemoteDependency(span, true);
@@ -318,11 +317,11 @@ private static void applySemanticConventions(
318317
return;
319318
}
320319
String azureNamespace = attributes.get(AZURE_NAMESPACE);
321-
if (azureNamespace != null && azureNamespace.equals("Microsoft.EventHub")) {
320+
if ("Microsoft.EventHub".equals(azureNamespace)) {
322321
applyEventHubsSpan(attributes, remoteDependencyData);
323322
return;
324323
}
325-
if (azureNamespace != null && azureNamespace.equals("Microsoft.ServiceBus")) {
324+
if ("Microsoft.ServiceBus".equals(azureNamespace)) {
326325
applyServiceBusSpan(attributes, remoteDependencyData);
327326
return;
328327
}
@@ -668,7 +667,8 @@ private static String getAzureSdkTargetSource(Attributes attributes) {
668667
private static int getDefaultPortForDbSystem(String dbSystem) {
669668
// jdbc default ports are from
670669
// io.opentelemetry.javaagent.instrumentation.jdbc.JdbcConnectionUrlParser
671-
// TODO make the ports constants (at least in JdbcConnectionUrlParser) so they can be used here
670+
// TODO (trask) make the ports constants (at least in JdbcConnectionUrlParser) so they can be
671+
// used here
672672
switch (dbSystem) {
673673
case SemanticAttributes.DbSystemValues.MONGODB:
674674
return 27017;
@@ -813,7 +813,7 @@ private boolean getSuccess(SpanData span) {
813813
case ERROR:
814814
return false;
815815
case OK:
816-
// auto-instrumentation never sets OK, so this is explicit user override
816+
// instrumentation never sets OK, so this is explicit user override
817817
return true;
818818
case UNSET:
819819
if (captureHttpServer4xxAsError) {
@@ -882,17 +882,14 @@ private static String getSource(Attributes attributes, SpanContext spanContext)
882882

883883
private static boolean isAzureQueue(Attributes attributes) {
884884
String azureNamespace = attributes.get(AZURE_NAMESPACE);
885-
if (azureNamespace == null) {
886-
return false;
887-
}
888-
return azureNamespace.equals("Microsoft.EventHub")
889-
|| azureNamespace.equals("Microsoft.ServiceBus");
885+
return "Microsoft.EventHub".equals(azureNamespace)
886+
|| "Microsoft.ServiceBus".equals(azureNamespace);
890887
}
891888

892889
private static String getOperationName(SpanData span) {
893890
String spanName = span.getName();
894891
String httpMethod = span.getAttributes().get(SemanticAttributes.HTTP_METHOD);
895-
if (!Strings.isNullOrEmpty(httpMethod) && spanName.startsWith("/")) {
892+
if (httpMethod != null && !httpMethod.isEmpty() && spanName.startsWith("/")) {
896893
return httpMethod + " " + spanName;
897894
}
898895
return spanName;
@@ -928,7 +925,7 @@ private void exportEvents(
928925

929926
if (event.getAttributes().get(SemanticAttributes.EXCEPTION_TYPE) != null
930927
|| event.getAttributes().get(SemanticAttributes.EXCEPTION_MESSAGE) != null) {
931-
// TODO map OpenTelemetry exception to Application Insights exception better
928+
// TODO (trask) map OpenTelemetry exception to Application Insights exception better
932929
String stacktrace = event.getAttributes().get(SemanticAttributes.EXCEPTION_STACKTRACE);
933930
if (stacktrace != null) {
934931
trackException(stacktrace, span, operationName, samplingPercentage);

0 commit comments

Comments
 (0)