azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

[BUG][OpenTelemetry] `request_charge` attribute (and others) has wrong type vs Otel Semantic conventions

Open lloydmeta opened this issue 8 months ago • 1 comments

Describe the bug

When using Cosmos client through azure-cosmos and azure-core-tracing-opentelemetry, I'm seeing spans that have ComosDB attributes (great !) but the type of some attributes that should be numeric appear to be exposed as strings instead vs semantic convention. This poses complications when I want to set up, say, alerts based on aggregations.

A concrete example is request_charge. When I use opentelemetry-exporter-logging-otlp, I can see a span like this:

                        {
                            "key": "db.cosmosdb.request_charge",
                            "value": {
                                "stringValue": "1.0"
                            }
                        },
                       // This one is also off
                       {
                           "key": "db.cosmosdb.sub_status_code",
                           "value": {
                              "stringValue": "0"
                            }
                       },
Full Cosmos scopeSpans entry
{
    "scope": {
        "name": "azure-cosmos",
        "version": "4.71.0",
        "attributes": []
    },
    "spans": [
        {
            "traceId": "64d788da1614eecadca306c4c50e7e81",
            "spanId": "5ca7a9f8cfc12e88",
            "parentSpanId": "cf6d237ebf78af06",
            "name": "readItem.api-keys",
            "kind": 1,
            "startTimeUnixNano": "1750239874590725791",
            "endTimeUnixNano": "1750239877364096250",
            "attributes": [
                {
                    "key": "exception.type",
                    "value": {
                        "stringValue": "com.azure.cosmos.CosmosException"
                    }
                },
                {
                    "key": "db.cosmosdb.resource_type",
                    "value": {
                        "stringValue": "Document"
                    }
                },
                {
                    "key": "az.namespace",
                    "value": {
                        "stringValue": "Microsoft.DocumentDB"
                    }
                },
                {
                    "key": "db.cosmosdb.status_code",
                    "value": {
                        "stringValue": "404"
                    }
                },
                {
                    "key": "exception.escaped",
                    "value": {
                        "stringValue": "false"
                    }
                },
                {
                    "key": "db.cosmosdb.sub_status_code",
                    "value": {
                        "stringValue": "0"
                    }
                },
                {
                    "key": "user_agent.original",
                    "value": {
                        "stringValue": "azsdk-java-cosmos/4.71.0 MacOSX/15.5 JRE/24.0.1"
                    }
                },
                {
                    "key": "db.cosmosdb.max_response_content_length_bytes",
                    "value": {
                        "intValue": "294"
                    }
                },
                {
                    "key": "db.cosmosdb.regions_contacted",
                    "value": {
                        "stringValue": "east us 2"
                    }
                },
                {
                    "key": "db.cosmosdb.connection_mode",
                    "value": {
                        "stringValue": "direct"
                    }
                },
                {
                    "key": "db.cosmosdb.container",
                    "value": {
                        "stringValue": "api-keys"
                    }
                },
                {
                    "key": "db.operation",
                    "value": {
                        "stringValue": "readItem.api-keys"
                    }
                },
                {
                    "key": "db.system",
                    "value": {
                        "stringValue": "cosmosdb"
                    }
                },
                {
                    "key": "error.type",
                    "value": {
                        "stringValue": "com.azure.cosmos.implementation.NotFoundException"
                    }
                },
                {
                    "key": "net.peer.name",
                    "value": {
                        "stringValue": "k8s-local-lloyd-iam"
                    }
                },
                {
                    "key": "db.cosmosdb.retry_count",
                    "value": {
                        "intValue": "0"
                    }
                },
                {
                    "key": "db.name",
                    "value": {
                        "stringValue": "lloyd-dev-iam"
                    }
                },
                {
                    "key": "exception.stacktrace",
                    "value": {
                        "stringValue": "\n\tat com.azure.cosmos.implementation.directconnectivity.rntbd.RntbdRequestManager.messageReceived(RntbdRequestManager.java:1108)\n\tat com.azure.cosmos.implementation.directconnectivity.rntbd.RntbdRequestManager.channelRead(RntbdRequestManager.java:226)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)\n\tat io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:289)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1519)\n\tat io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1377)\n\tat io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1428)\n\tat io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:530)\n\tat io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:469)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1357)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:868)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:796)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:697)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:660)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:998)\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n\tat java.base/java.lang.Thread.run(Thread.java:1447)\n"
                    }
                },
                {
                    "key": "db.cosmosdb.request_charge",
                    "value": {
                        "stringValue": "1.0"
                    }
                },
                {
                    "key": "db.cosmosdb.request_content_length",
                    "value": {
                        "intValue": "462"
                    }
                },
                {
                    "key": "db.cosmosdb.client_id",
                    "value": {
                        "stringValue": "00001"
                    }
                },
                {
                    "key": "db.cosmosdb.operation_type",
                    "value": {
                        "stringValue": "Read"
                    }
                }
            ],
            "events": [
                {
                    "timeUnixNano": "1750239877357120000",
                    "name": "ThresholdViolation - CTX: {\"spanName\":\"readItem.api-keys\",\"account\":\"k8s-local-lloyd-iam\",\"db\":\"lloyd-dev-iam\",\"container\":\"api-keys\",\"resource\":\"Document\",\"operation\":\"Read\",\"consistency\":\"Eventual\",\"readConsistencyStrategy\":\"Default\",\"status\":404,\"durationInMs\":2745.858,\"RUs\":1.0,\"maxRequestSizeInBytes\":462,\"maxResponseSizeInBytes\":294,\"exception\":\"{\\\"ClassName\\\":\\\"NotFoundException\\\",\\\"userAgent\\\":\\\"azsdk-java-cosmos/4.71.0 MacOSX/15.5 JRE/24.0.1\\\",\\\"statusCode\\\":404,\\\"resourceAddress\\\":\\\"rntbd://cdb-ms-prod-eastus2-be307.documents.azure.com:14075/apps/92da941d-5b28-4f69-8343-bb6c0b41f4f2/services/d43a88fb-3e98-4395-ade9-70676fc6348b/partitions/0b1cf87f-0c8b-4241-9593-82f489ab3469/replicas/133945920105666762p/\\\",\\\"error\\\":\\\"{\\\\\\\"Errors\\\\\\\":[\\\\\\\"Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found\\\\\\\"]}\\\",\\\"innerErrorMessage\\\":\\\"[\\\\\\\"Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found\\\\\\\"]\\\",\\\"causeInfo\\\":null,\\\"responseHeaders\\\":\\\"{x-ms-current-replica-set-size=4, x-ms-last-state-change-utc=Tue, 17 Jun 2025 00:00:13.250 GMT, x-ms-request-duration-ms=20.175, x-ms-session-token=0:-1#5, lsn=5, x-ms-request-charge=1.00, x-ms-schemaversion=1.19, x-ms-transport-request-id=1, x-ms-number-of-read-regions=0, x-ms-current-write-quorum=3, x-ms-cosmos-quorum-acked-llsn=5, x-ms-quorum-acked-lsn=5, x-ms-activity-id=6eb06bb1-e4df-4332-9936-27f94259d34e, x-ms-xp-role=1, x-ms-global-Committed-lsn=5, x-ms-cosmos-llsn=5, x-ms-serviceversion= version=2.14.0.0}\\\"}\",\"diagnostics\":[{\"cosmosDiagnostics\":{\"userAgent\":\"azsdk-java-cosmos/4.71.0 MacOSX/15.5 JRE/24.0.1\",\"activityId\":\"6eb06bb1-e4df-4332-9936-27f94259d34e\",\"requestLatencyInMs\":2745,\"requestStartTimeUTC\":\"2025-06-18T09:44:34.588648Z\",\"requestEndTimeUTC\":\"2025-06-18T09:44:37.334559Z\",\"responseStatisticsList\":[{\"store_result\":{\"storePhysicalAddress\":\"rntbd://cdb-ms-prod-eastus2-be307.documents.azure.com:14075/apps/92da941d-5b28-4f69-8343-bb6c0b41f4f2/services/d43a88fb-3e98-4395-ade9-70676fc6348b/partitions/0b1cf87f-0c8b-4241-9593-82f489ab3469/replicas/133945920105666762p/\",\"lsn\":5,\"quorumAckedLSN\":5,\"currentReplicaSetSize\":3,\"globalCommittedLsn\":5,\"partitionKeyRangeId\":\"0\",\"isValid\":true,\"statusCode\":404,\"subStatusCode\":0,\"isGone\":false,\"isNotFound\":true,\"isInvalidPartition\":false,\"isThroughputControlRequestRateTooLarge\":false,\"requestCharge\":1.0,\"itemLSN\":-1,\"sessionToken\":\"0:-1#5\",\"backendLatencyInMs\":20.175,\"retryAfterInMs\":null,\"exceptionMessage\":\"[\\\"Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found\\\"]\",\"exceptionResponseHeaders\":\"{x-ms-current-replica-set-size=4, x-ms-last-state-change-utc=Tue, 17 Jun 2025 00:00:13.250 GMT, x-ms-request-duration-ms=20.175, x-ms-session-token=0:-1#5, lsn=5, x-ms-request-charge=1.00, x-ms-schemaversion=1.19, x-ms-transport-request-id=1, x-ms-number-of-read-regions=0, x-ms-current-write-quorum=3, x-ms-cosmos-quorum-acked-llsn=5, x-ms-quorum-acked-lsn=5, x-ms-activity-id=6eb06bb1-e4df-4332-9936-27f94259d34e, x-ms-xp-role=1, x-ms-global-Committed-lsn=5, x-ms-cosmos-llsn=5, x-ms-documentdb-partitionkeyrangeid=0, x-ms-serviceversion= version=2.14.0.0}\",\"replicaStatusList\":{\"Ignoring\":[],\"Attempting\":[\"14075:P:Unknown\",\"14305:S:Unknown\",\"14043:S:Unknown\",\"14446:S:Unknown\"]},\"transportRequestTimeline\":[{\"eventName\":\"created\",\"startTimeUTC\":\"2025-06-18T09:44:36.164910Z\",\"duration_in_milli_secs\":13.084},{\"eventName\":\"queued\",\"startTimeUTC\":\"2025-06-18T09:44:36.177994Z\",\"duration_in_milli_secs\":0.037},{\"eventName\":\"channelAcquisitionStarted\",\"startTimeUTC\":\"2025-06-18T09:44:36.178031Z\",\"duration_in_milli_secs\":878.575},{\"eventName\":\"pipelined\",\"startTimeUTC\":\"2025-06-18T09:44:37.056606Z\",\"duration_in_milli_secs\":37.156},{\"eventName\":\"transitTime\",\"startTimeUTC\":\"2025-06-18T09:44:37.093762Z\",\"duration_in_milli_secs\":222.993},{\"eventName\":\"decodeTime\",\"startTimeUTC\":\"2025-06-18T09:44:37.316755Z\",\"duration_in_milli_secs\":2.669},{\"eventName\":\"received\",\"startTimeUTC\":\"2025-06-18T09:44:37.319424Z\",\"duration_in_milli_secs\":13.295},{\"eventName\":\"completed\",\"startTimeUTC\":\"2025-06-18T09:44:37.332719Z\",\"duration_in_milli_secs\":0.037}],\"rntbdRequestLengthInBytes\":462,\"rntbdResponseLengthInBytes\":294,\"requestPayloadLengthInBytes\":0,\"responsePayloadLengthInBytes\":294,\"channelStatistics\":{\"channelId\":\"91e25c24\",\"channelTaskQueueSize\":0,\"pendingRequestsCount\":0,\"lastReadTime\":\"2025-06-18T09:44:37.055962Z\",\"waitForConnectionInit\":true},\"serviceEndpointStatistics\":{\"availableChannels\":0,\"acquiredChannels\":0,\"executorTaskQueueSize\":0,\"inflightRequests\":1,\"lastSuccessfulRequestTime\":\"2025-06-18T09:44:36.168Z\",\"lastRequestTime\":\"2025-06-18T09:44:36.168Z\",\"createdTime\":\"2025-06-18T09:44:36.168453Z\",\"isClosed\":false,\"cerMetrics\":{}}},\"request_response_time_utc\":\"2025-06-18T09:44:37.334559Z\",\"request_start_time_utc\":\"2025-06-18T09:44:36.164910Z\",\"request_resource_type\":\"Document\",\"request_operation_type\":\"Read\",\"session_token_evaluation_results\":[]}],\"supplementalResponseStatisticsList\":[],\"addressResolutionStatistics\":{\"315d82af-353d-4fca-aebb-f25e7aeacf19\":{\"start_time_utc\":\"2025-06-18T09:44:35.979721Z\",\"end_time_utc\":\"2025-06-18T09:44:36.158338Z\",\"target_endpoint\":\"https://k8s-local-lloyd-iam-eastus2.documents.azure.com:443/addresses/?$resolveFor=dbs%2Fl9hQAA%3D%3D%2Fcolls%2Fl9hQAJnoW3Y%3D%2Fdocs&$filter=protocol%20eq%20rntbd&$partitionKeyRangeIds=0\",\"force_refresh\":false,\"force_collection_routing_map_refresh\":false,\"inflight_request\":false}},\"regionsContacted\":[\"east us 2\"],\"retryContext\":{\"retry_latency\":0,\"retry_count\":0},\"metadataDiagnosticsContext\":{\"metadata_diagnostic_list\":[{\"metaDataName\":\"CONTAINER_LOOK_UP\",\"startTimeUTC\":\"2025-06-18T09:44:34.592957Z\",\"endTimeUTC\":\"2025-06-18T09:44:35.344907Z\",\"durationinMS\":751},{\"metaDataName\":\"PARTITION_KEY_RANGE_LOOK_UP\",\"startTimeUTC\":\"2025-06-18T09:44:35.349914Z\",\"endTimeUTC\":\"2025-06-18T09:44:35.965568Z\",\"durationinMS\":615},{\"metaDataName\":\"SERVER_ADDRESS_LOOKUP\",\"startTimeUTC\":\"2025-06-18T09:44:35.979737Z\",\"endTimeUTC\":\"2025-06-18T09:44:36.158302Z\",\"durationinMS\":178}]},\"serializationDiagnosticsContext\":{},\"gatewayStatisticsList\":[],\"samplingRateSnapshot\":1.0,\"bloomFilterInsertionCountSnapshot\":0,\"systemInformation\":{\"used_memory\":\"126498 KB\",\"available_memory\":\"8262110 KB\",\"system_cpu_load\":\"empty\",\"available_processors\":12},\"clientCfgs\":{\"id\":1,\"machineId\":\"uuid:b2ea9c01-62c1-4d56-891b-c4770c6988f6\",\"connectionMode\":\"DIRECT\",\"numberOfClients\":1,\"isPpafEnabled\":\"\",\"isFalseProgSessionTokenMergeEnabled\":\"true\",\"excrgns\":\"[]\",\"clientEndpoints\":{\"https://k8s-local-lloyd-iam.documents.azure.com:443\":1},\"connCfg\":{\"rntbd\":\"(cto:PT5S, nrto:PT5S, icto:PT0S, ieto:PT1H, mcpe:130, mrpc:30, cer:true)\",\"gw\":\"(cps:1000, nrto:PT1M, icto:PT1M, cto:PT45S, p:false, http2:(enabled:false, maxc:1000, minc:1, maxs:30))\",\"other\":\"(ed: true, cs: false, rv: true)\"},\"consistencyCfg\":\"(consistency: null, readConsistencyStrategy: null,  mm: true, prgns: [])\",\"proactiveInitCfg\":\"\",\"e2ePolicyCfg\":\"\",\"sessionRetryCfg\":\"\",\"partitionLevelCircuitBreakerCfg\":\"(cb: false, type: CONSECUTIVE_EXCEPTION_COUNT_BASED, rexcntt: 10, wexcntt: 5)\"}}}]}",
                    "attributes": [
                        {
                            "key": "SequenceNumber",
                            "value": {
                                "stringValue": "00001"
                            }
                        },
                        {
                            "key": "Trigger",
                            "value": {
                                "stringValue": "ThresholdViolation"
                            }
                        }
                    ]
                }
            ],
            "links": [],
            "status": {
                "message": "{\"innerErrorMessage\":\"[\\\"Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found\\\"]\",\"cosmosDiagnostics\":{\"userAgent\":\"azsdk-java-cosmos/4.71.0 MacOSX/15.5 JRE/24.0.1\",\"activityId\":\"6eb06bb1-e4df-4332-9936-27f94259d34e\",\"requestLatencyInMs\":2745,\"requestStartTimeUTC\":\"2025-06-18T09:44:34.588648Z\",\"requestEndTimeUTC\":\"2025-06-18T09:44:37.334559Z\",\"responseStatisticsList\":[{\"storeResult\":{\"storePhysicalAddress\":\"rntbd://cdb-ms-prod-eastus2-be307.documents.azure.com:14075/apps/92da941d-5b28-4f69-8343-bb6c0b41f4f2/services/d43a88fb-3e98-4395-ade9-70676fc6348b/partitions/0b1cf87f-0c8b-4241-9593-82f489ab3469/replicas/133945920105666762p/\",\"lsn\":5,\"quorumAckedLSN\":5,\"currentReplicaSetSize\":3,\"globalCommittedLsn\":5,\"partitionKeyRangeId\":\"0\",\"isValid\":true,\"statusCode\":404,\"subStatusCode\":0,\"isGone\":false,\"isNotFound\":true,\"isInvalidPartition\":false,\"isThroughputControlRequestRateTooLarge\":false,\"requestCharge\":1.0,\"itemLSN\":-1,\"sessionToken\":\"0:-1#5\",\"backendLatencyInMs\":20.175,\"retryAfterInMs\":null,\"exceptionMessage\":\"[\\\"Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found\\\"]\",\"exceptionResponseHeaders\":\"{x-ms-current-replica-set-size=4, x-ms-last-state-change-utc=Tue, 17 Jun 2025 00:00:13.250 GMT, x-ms-request-duration-ms=20.175, x-ms-session-token=0:-1#5, lsn=5, x-ms-request-charge=1.00, x-ms-schemaversion=1.19, x-ms-transport-request-id=1, x-ms-number-of-read-regions=0, x-ms-current-write-quorum=3, x-ms-cosmos-quorum-acked-llsn=5, x-ms-quorum-acked-lsn=5, x-ms-activity-id=6eb06bb1-e4df-4332-9936-27f94259d34e, x-ms-xp-role=1, x-ms-global-Committed-lsn=5, x-ms-cosmos-llsn=5, x-ms-documentdb-partitionkeyrangeid=0, x-ms-serviceversion= version=2.14.0.0}\",\"replicaStatusList\":{\"Ignoring\":[],\"Attempting\":[\"14075:P:Unknown\",\"14305:S:Unknown\",\"14043:S:Unknown\",\"14446:S:Unknown\"]},\"transportRequestTimeline\":[{\"eventName\":\"created\",\"startTimeUTC\":\"2025-06-18T09:44:36.164910Z\",\"durationInMilliSecs\":13.084},{\"eventName\":\"queued\",\"startTimeUTC\":\"2025-06-18T09:44:36.177994Z\",\"durationInMilliSecs\":0.037},{\"eventName\":\"channelAcquisitionStarted\",\"startTimeUTC\":\"2025-06-18T09:44:36.178031Z\",\"durationInMilliSecs\":878.575},{\"eventName\":\"pipelined\",\"startTimeUTC\":\"2025-06-18T09:44:37.056606Z\",\"durationInMilliSecs\":37.156},{\"eventName\":\"transitTime\",\"startTimeUTC\":\"2025-06-18T09:44:37.093762Z\",\"durationInMilliSecs\":222.993},{\"eventName\":\"decodeTime\",\"startTimeUTC\":\"2025-06-18T09:44:37.316755Z\",\"durationInMilliSecs\":2.669},{\"eventName\":\"received\",\"startTimeUTC\":\"2025-06-18T09:44:37.319424Z\",\"durationInMilliSecs\":13.295},{\"eventName\":\"completed\",\"startTimeUTC\":\"2025-06-18T09:44:37.332719Z\",\"durationInMilliSecs\":0.037}],\"rntbdRequestLengthInBytes\":462,\"rntbdResponseLengthInBytes\":294,\"requestPayloadLengthInBytes\":0,\"responsePayloadLengthInBytes\":294,\"channelStatistics\":{\"channelId\":\"91e25c24\",\"channelTaskQueueSize\":0,\"pendingRequestsCount\":0,\"lastReadTime\":\"2025-06-18T09:44:37.055962Z\",\"waitForConnectionInit\":true},\"serviceEndpointStatistics\":{\"availableChannels\":0,\"acquiredChannels\":0,\"executorTaskQueueSize\":0,\"inflightRequests\":1,\"lastSuccessfulRequestTime\":\"2025-06-18T09:44:36.168Z\",\"lastRequestTime\":\"2025-06-18T09:44:36.168Z\",\"createdTime\":\"2025-06-18T09:44:36.168453Z\",\"isClosed\":false,\"cerMetrics\":{}}},\"requestResponseTimeUTC\":\"2025-06-18T09:44:37.334559Z\",\"requestStartTimeUTC\":\"2025-06-18T09:44:36.164910Z\",\"requestResourceType\":\"Document\",\"requestOperationType\":\"Read\",\"requestSessionToken\":null,\"e2ePolicyCfg\":null,\"excludedRegions\":null,\"sessionTokenEvaluationResults\":[],\"perPartitionCircuitBreakerInfoHolder\":null,\"perPartitionFailoverInfoHolder\":null}],\"supplementalResponseStatisticsList\":[],\"addressResolutionStatistics\":{\"315d82af-353d-4fca-aebb-f25e7aeacf19\":{\"startTimeUTC\":\"2025-06-18T09:44:35.979721Z\",\"endTimeUTC\":\"2025-06-18T09:44:36.158338Z\",\"targetEndpoint\":\"https://k8s-local-lloyd-iam-eastus2.documents.azure.com:443/addresses/?$resolveFor=dbs%2Fl9hQAA%3D%3D%2Fcolls%2Fl9hQAJnoW3Y%3D%2Fdocs&$filter=protocol%20eq%20rntbd&$partitionKeyRangeIds=0\",\"exceptionMessage\":null,\"forceRefresh\":false,\"forceCollectionRoutingMapRefresh\":false,\"inflightRequest\":false}},\"regionsContacted\":[\"east us 2\"],\"retryContext\":{\"statusAndSubStatusCodes\":null,\"retryLatency\":0,\"retryCount\":0},\"metadataDiagnosticsContext\":{\"metadataDiagnosticList\":[{\"metaDataName\":\"CONTAINER_LOOK_UP\",\"startTimeUTC\":\"2025-06-18T09:44:34.592957Z\",\"endTimeUTC\":\"2025-06-18T09:44:35.344907Z\",\"durationinMS\":751},{\"metaDataName\":\"PARTITION_KEY_RANGE_LOOK_UP\",\"startTimeUTC\":\"2025-06-18T09:44:35.349914Z\",\"endTimeUTC\":\"2025-06-18T09:44:35.965568Z\",\"durationinMS\":615},{\"metaDataName\":\"SERVER_ADDRESS_LOOKUP\",\"startTimeUTC\":\"2025-06-18T09:44:35.979737Z\",\"endTimeUTC\":\"2025-06-18T09:44:36.158302Z\",\"durationinMS\":178}]},\"serializationDiagnosticsContext\":{\"serializationDiagnosticsList\":null},\"gatewayStatisticsList\":[],\"samplingRateSnapshot\":1.0,\"bloomFilterInsertionCountSnapshot\":0,\"systemInformation\":{\"usedMemory\":\"128239 KB\",\"availableMemory\":\"8260369 KB\",\"systemCpuLoad\":\"empty\",\"availableProcessors\":12},\"clientCfgs\":{\"id\":1,\"machineId\":\"uuid:b2ea9c01-62c1-4d56-891b-c4770c6988f6\",\"connectionMode\":\"DIRECT\",\"numberOfClients\":1,\"isPpafEnabled\":\"\",\"isFalseProgSessionTokenMergeEnabled\":\"true\",\"excrgns\":\"[]\",\"clientEndpoints\":{\"https://k8s-local-lloyd-iam.documents.azure.com:443\":1},\"connCfg\":{\"rntbd\":\"(cto:PT5S, nrto:PT5S, icto:PT0S, ieto:PT1H, mcpe:130, mrpc:30, cer:true)\",\"gw\":\"(cps:1000, nrto:PT1M, icto:PT1M, cto:PT45S, p:false, http2:(enabled:false, maxc:1000, minc:1, maxs:30))\",\"other\":\"(ed: true, cs: false, rv: true)\"},\"consistencyCfg\":\"(consistency: null, readConsistencyStrategy: null,  mm: true, prgns: [])\",\"proactiveInitCfg\":\"\",\"e2ePolicyCfg\":\"\",\"sessionRetryCfg\":\"\",\"partitionLevelCircuitBreakerCfg\":\"(cb: false, type: CONSECUTIVE_EXCEPTION_COUNT_BASED, rexcntt: 10, wexcntt: 5)\"}}}",
                "code": 2
            },
            "flags": 257
        }
    ],
    "schemaUrl": "https://opentelemetry.io/schemas/1.23.1"
}

I think this is a bug given there are 2 places that mention that this should be a double:

  • For db.cosmosdb.request_charge (the current one): https://github.com/open-telemetry/semantic-conventions/blob/723789b86a803492d03191b458138fff6e7a6b9f/docs/registry/attributes/db.md#db-cosmosdb-request-charge
  • For azure.cosmosdb.operation.request_charge https://opentelemetry.io/docs/specs/semconv/registry/attributes/azure/#azure-cosmosdb-operation-request-charge

Note that not all attributes are wrong; db.cosmosdb.request_content_length for instance is correct.

Exception or Stack Trace n/a

To Reproduce Send Otel traces with CosmosDB client + otel exporter (or log with opentelemetry-exporter-logging-otlp)

Code Snippet n/a

Expected behavior

  • The types of the attributes to adhere to Otel semantic conventions
  • There should be the non-deprecated attributes (e.g. azure.cosmosdb.operation.request_charge instead of or in addition to db.cosmosdb.request_charge

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: Linux/Mac
  • IDE: IntelliJ
  • Library/Libraries:
    implementation("com.azure:azure-cosmos:4.71.0")
    implementation("com.azure:azure-core-tracing-opentelemetry:1.0.0-beta.57")
    implementation("io.opentelemetry:opentelemetry-exporter-logging-otlp")
    
  • Java version: 24
  • App Server/Environment: k8s
  • Frameworks: Quarkus

Additional context n/a

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [x] Bug Description Added
  • [x] Repro Steps Added
  • [x] Setup information Added

lloydmeta avatar Jun 18 '25 10:06 lloydmeta

Took a stab at fixing this in #45753

Based on my reading of the PR that introduced these labels, https://github.com/Azure/azure-sdk-for-java/pull/33209, and the PR adding the semantic conventions for Cosmos https://github.com/open-telemetry/opentelemetry-specification/pull/3097, I think the types mismatch was simply a simple oversight.

lloydmeta avatar Jun 18 '25 13:06 lloydmeta