Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better mapping of cosmos telemetry #2906

Merged
merged 5 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public final class AiSemanticAttributes {
AttributeKey.stringKey("message_bus.destination");
public static final AttributeKey<Long> AZURE_SDK_ENQUEUED_TIME =
AttributeKey.longKey("x-opt-enqueued-time");
public static final AttributeKey<String> AZURE_SDK_DB_TYPE = AttributeKey.stringKey("db.type");
public static final AttributeKey<String> AZURE_SDK_DB_INSTANCE =
AttributeKey.stringKey("db.instance");
public static final AttributeKey<String> AZURE_SDK_DB_URL = AttributeKey.stringKey("db.url");

public static final AttributeKey<Long> KAFKA_RECORD_QUEUE_TIME_MS =
AttributeKey.longKey("kafka.record.queue_time_ms");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ private static void applySemanticConventions(
return;
}
String dbSystem = attributes.get(SemanticAttributes.DB_SYSTEM);
if (dbSystem == null) {
// special case needed until Azure SDK moves to latest OTel semantic conventions
dbSystem = attributes.get(AiSemanticAttributes.AZURE_SDK_DB_TYPE);
}
if (dbSystem != null) {
applyDatabaseClientSpan(telemetryBuilder, dbSystem, attributes);
return;
Expand Down Expand Up @@ -392,16 +396,31 @@ private static void applyDatabaseClientSpan(
} else {
type = "SQL";
}
} else if (dbSystem.equals("Cosmos")) {
trask marked this conversation as resolved.
Show resolved Hide resolved
// this has special icon in portal (documentdb was the old name for cosmos)
type = "azure documentdb";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had a long conversation between portal and cosmos team and decided that using RP namespace is the best choice (Microsoft.DocumentDB for client spans, InProc | Microsoft.DocumentDB for internal spans)

/~https://github.com/microsoft/ApplicationInsights-dotnet/blob/18be714998a846aba7e9b673d47eece67be2d3dc/WEB/Src/DependencyCollector/DependencyCollector/Implementation/AzureSdk/AzureSdkDiagnosticsEventHandler.cs#L20-L22

If it's not implemented on the portal yet, it should be soon (cc @OsvaldoRosado)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx! Microsoft.DocumentDB didn't have an image yet when I tested, but went ahead and changed it to avoid churn on the data 👍

} else {
type = dbSystem;
}
telemetryBuilder.setType(type);
telemetryBuilder.setData(dbStatement);
String target =
nullAwareConcat(
getTargetOrDefault(attributes, getDefaultPortForDbSystem(dbSystem), dbSystem),
attributes.get(SemanticAttributes.DB_NAME),
" | ");

String target;
String dbName;
if (dbSystem.equals("Cosmos")) {
// special case needed until Azure SDK moves to latest OTel semantic conventions
String dbUrl = attributes.get(AiSemanticAttributes.AZURE_SDK_DB_URL);
if (dbUrl != null) {
target = UrlParser.getTarget(dbUrl);
} else {
target = null;
}
dbName = attributes.get(AiSemanticAttributes.AZURE_SDK_DB_INSTANCE);
} else {
target = getTargetOrDefault(attributes, getDefaultPortForDbSystem(dbSystem), dbSystem);
dbName = attributes.get(SemanticAttributes.DB_NAME);
}
target = nullAwareConcat(target, dbName, " | ");
if (target == null) {
target = dbSystem;
}
Expand Down