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

Add support for stable HTTP semconv #37899

Merged
merged 5 commits into from
Jan 5, 2024
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 @@ -70,14 +70,6 @@ public final class AiSemanticAttributes {
public static final AttributeKey<String> DEVICE_OS_VERSION =
AttributeKey.stringKey("applicationinsights.internal.operating_system_version");

// TODO (trask) remove these once they make it into SemanticAttributes
public static final AttributeKey<String> NET_SOCK_PEER_NAME =
AttributeKey.stringKey("net.sock.peer.name");
public static final AttributeKey<String> NET_SOCK_PEER_ADDR =
AttributeKey.stringKey("net.sock.peer.addr");
public static final AttributeKey<Long> NET_SOCK_PEER_PORT =
AttributeKey.longKey("net.sock.peer.port");

public static final AttributeKey<String> LEGACY_PARENT_ID =
AttributeKey.stringKey("applicationinsights.internal.legacy_parent_id");
public static final AttributeKey<String> LEGACY_ROOT_ID =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class MappingsBuilder {
private static final Set<String> STANDARD_ATTRIBUTE_PREFIXES =
new HashSet<>(
asList(
"server.",
"client.",
"network.",
"url.",
"error.",
"http.",
"db.",
"message.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import static com.azure.monitor.opentelemetry.exporter.implementation.AiSemanticAttributes.IS_SYNTHETIC;
import static com.azure.monitor.opentelemetry.exporter.implementation.MappingsBuilder.EMPTY_MAPPINGS;
import static com.azure.monitor.opentelemetry.exporter.implementation.SpanDataMapper.getStableAttribute;
import static io.opentelemetry.api.internal.Utils.checkArgument;
import static io.opentelemetry.sdk.metrics.data.MetricDataType.DOUBLE_GAUGE;
import static io.opentelemetry.sdk.metrics.data.MetricDataType.DOUBLE_SUM;
Expand All @@ -54,10 +55,12 @@ public class MetricDataMapper {
EXCLUDED_METRIC_NAMES.add("http.server.response.size");
EXCLUDED_METRIC_NAMES.add("http.client.response.size");

OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("http.server.duration"); // Servlet
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("http.client.duration"); // HttpClient
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("rpc.client.duration"); // gRPC
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("rpc.server.duration"); // gRPC
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("http.server.request.duration");
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("http.client.request.duration");
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("http.server.duration"); // pre-stable HTTP semconv
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("http.client.duration"); // pre-stable HTTP semconv
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("rpc.client.duration");
OTEL_PRE_AGGREGATED_STANDARD_METRIC_NAMES.add("rpc.server.duration");
}

public MetricDataMapper(
Expand Down Expand Up @@ -156,7 +159,7 @@ public static void updateMetricPointBuilder(

Attributes attributes = pointData.getAttributes();
if (isPreAggregatedStandardMetric) {
Long statusCode = attributes.get(SemanticAttributes.HTTP_STATUS_CODE);
Long statusCode = getStableAttribute(attributes, SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, SemanticAttributes.HTTP_STATUS_CODE);
boolean success = isSuccess(statusCode, captureHttpServer4xxAsError);
Boolean isSynthetic = attributes.get(IS_SYNTHETIC);

Expand All @@ -172,7 +175,7 @@ public static void updateMetricPointBuilder(
int defaultPort;
if (metricData.getName().startsWith("http")) {
dependencyType = "Http";
defaultPort = getDefaultPortForHttpScheme(attributes.get(SemanticAttributes.HTTP_SCHEME));
defaultPort = getDefaultPortForHttpScheme(getStableAttribute(attributes, SemanticAttributes.URL_SCHEME, SemanticAttributes.HTTP_SCHEME));
} else {
dependencyType = attributes.get(SemanticAttributes.RPC_SYSTEM);
if (dependencyType == null) {
Expand Down
Loading
Loading