From c60e5b17e4a66d1fd05bb76178ff9c2f75014d21 Mon Sep 17 00:00:00 2001 From: nirsky Date: Wed, 18 Nov 2020 15:40:20 +0200 Subject: [PATCH 1/3] feat(semantic-conventions): messaging specifications --- .../src/trace/index.ts | 1 + .../src/trace/messaging.ts | 134 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 packages/opentelemetry-semantic-conventions/src/trace/messaging.ts diff --git a/packages/opentelemetry-semantic-conventions/src/trace/index.ts b/packages/opentelemetry-semantic-conventions/src/trace/index.ts index 6c9c017c5e..20b5ebd5d5 100644 --- a/packages/opentelemetry-semantic-conventions/src/trace/index.ts +++ b/packages/opentelemetry-semantic-conventions/src/trace/index.ts @@ -21,3 +21,4 @@ export * from './http'; export * from './os'; export * from './rpc'; export * from './faas'; +export * from './messaging'; diff --git a/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts b/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts new file mode 100644 index 0000000000..1a67575ff1 --- /dev/null +++ b/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts @@ -0,0 +1,134 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * messaging attribute names defined by the Opetelemetry Semantic Conventions specification + * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/messaging.md + */ +export const MessagingAttribute = { + /** + * A string identifying the messaging system. + * example: kafka, rabbitmq, sqs, sns + * + * @remarks + * Required. + */ + MESSAGING_SYSTEM: 'messaging.system', + + /** + * The message destination name. This might be equal to the span name but is required nevertheless. + * example: MyQueue, MyTopic + * + * @remarks + * Required. + */ + MESSAGING_DESTINATION: 'messaging.destination', + + /** + * The kind of message destination + * allowed values: queue, topic, + * + * @remarks + * Required only if the message destination is either a queue or topic. + */ + MESSAGING_DESTINATION_KIND: 'messaging.destination.kind', + + /** + * A boolean that is true if the message destination is temporary + * + * @remarks + * Conditional If missing, it is assumed to be false. + */ + MESSAGING_TEMP_DESTINATION: 'messaging.temp_destination', + + /** + * The kind of message destination + * allowed values: queue, topic, + * + * @remarks + * Required only if the message destination is either a queue or topic. + */ + MESSAGING_PROTOCOL: 'messaging.protocol', + + /** + * The version of the transport protocol. + * + * @remarks + * Optional. + */ + MESSAGING_PROTOCOL_VERSION: 'messaging.protocol_version', + + /** + * Connection string. + * example: https://queue.amazonaws.com/80398EXAMPLE/MyQueue + * + * @remarks + * Optional. + */ + MESSAGING_URL: 'messaging.url', + + /** + * A value used by the messaging system as an identifier for the message, represented as a string. + * + * @remarks + * Optional. + */ + MESSAGING_MESSAGE_ID: 'messaging.message_id', + + /** + * The conversation ID identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". + * + * @remarks + * Optional. + */ + MESSAGING_CONVERSATION_ID: 'messaging.conversation_id', + + /** + * The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. + * Should be number. + * + * @remarks + * Optional. + */ + MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES: 'messaging.message_payload_size_bytes', + + /** + * The compressed size of the message payload in bytes. + * Should be number. + * + * @remarks + * Optional. + */ + MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES: + 'messaging.message_payload_compressed_size_bytes', + + /** + * For message consumers only. + * allowed values: receive, process, + * + * @remarks + * Optional. + */ + MESSAGING_OPERATION: 'messaging.operation', + + // System specific attributes + MESSAGING_RABBITMQ_ROUTING_KEY: 'messaging.rabbitmq.routing_key', + MESSAGING_KAFKA_MESSAGE_KEY: 'messaging.kafka.message_key', + MESSAGING_KAFKA_CONSUMER_GROUP: 'messaging.kafka.consumer_group', + MESSAGING_KAFKA_CLIENT_ID: 'messaging.kafka.client_id', + MESSAGING_KAFKA_PARTITION: 'messaging.kafka.partition', + MESSAGING_KAFKA_TOMBSTONE: 'messaging.kafka.tombstone', +}; From 47f78d3fb0cbe481d8b0ee548dc73ca1e96feed5 Mon Sep 17 00:00:00 2001 From: Nir Hadassi Date: Wed, 18 Nov 2020 17:41:14 +0200 Subject: [PATCH 2/3] Update packages/opentelemetry-semantic-conventions/src/trace/messaging.ts Co-authored-by: Bartlomiej Obecny --- .../opentelemetry-semantic-conventions/src/trace/messaging.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts b/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts index 1a67575ff1..bb71687e78 100644 --- a/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts +++ b/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts @@ -44,7 +44,7 @@ export const MessagingAttribute = { * @remarks * Required only if the message destination is either a queue or topic. */ - MESSAGING_DESTINATION_KIND: 'messaging.destination.kind', + MESSAGING_DESTINATION_KIND: 'messaging.destination_kind', /** * A boolean that is true if the message destination is temporary From c13b80b41271a441b57172717fc82fa9d8c2c577 Mon Sep 17 00:00:00 2001 From: nirsky Date: Wed, 18 Nov 2020 18:16:58 +0200 Subject: [PATCH 3/3] fix: added MessagingOperationName --- .../src/trace/messaging.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts b/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts index bb71687e78..c5266a60a2 100644 --- a/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts +++ b/packages/opentelemetry-semantic-conventions/src/trace/messaging.ts @@ -132,3 +132,20 @@ export const MessagingAttribute = { MESSAGING_KAFKA_PARTITION: 'messaging.kafka.partition', MESSAGING_KAFKA_TOMBSTONE: 'messaging.kafka.tombstone', }; + +export const MessagingOperationName = { + /** + * A message is sent to a destination by a message producer/client. + */ + SEND: 'send', + + /** + * A message is received from a destination by a message consumer/server. + */ + RECEIVE: 'receive', + + /** + * A message that was previously received from a destination is processed by a message consumer/server. + */ + PROCESS: 'process', +};