Skip to content

Commit

Permalink
lambda samples
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Nov 10, 2022
1 parent fe954e4 commit 747411a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 49 deletions.
6 changes: 3 additions & 3 deletions schemas/1.15.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ versions:
changes:
- rename_attributes:
attribute_map:
# https://github.com/open-telemetry/opentelemetry-specification/pull/2743
# https://github.com/open-telemetry/opentelemetry-specification/pull/2743
http.retry_count: http.resend_count
# https://github.com/open-telemetry/opentelemetry-specification/pull/2763
messaging.protocol: net.app.protocol.name
messaging.protocol_version: net.app.protocol.version
messaging.destination: messaging.destination.name
messaging.temp_destination: messaging.destination.temporary,
messaging.destination_kind: messaging.destination.kind,
messaging.temp_destination: messaging.destination.temporary
messaging.destination_kind: messaging.destination.kind
messaging.message_id: messaging.message.id
messaging.conversation_id: messaging.message.conversation_id
messaging.message_payload_size_bytes: messaging.message.payload_size_bytes
Expand Down
25 changes: 17 additions & 8 deletions semantic_conventions/trace/messaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,23 @@ groups:
conditionally_required: >
If available within the messaging system, and only if the span describes operations that operate with message batches.
note: >
Instrumentation SHOULD always set it on batch `receive` operations regardless
Instrumentation MUST set it on batch `receive` operations regardless
of the actual number of received messages (e.g. 0, 1, or more).
Instrumentations SHOULD set `messaging.batch.size` on spans representing
other operations - when it's not set, it's assumed to be `1`.
examples: [0, 1, 2]
- ref: messaging.message.id
requirement_level:
recommended: Only if span represents operation on a single message.
- ref: messaging.message.conversation_id
requirement_level:
recommended: Only if messaging.batch.size is not set or if the value applies to all messages in the batch.
- ref: messaging.message.payload_size_bytes
requirement_level:
recommended: Only if messaging.batch.size is not set or if the value applies to all messages in the batch.
recommended: Only if span represents operation on a single message.
- ref: messaging.message.payload_compressed_size_bytes
requirement_level:
recommended: Only if messaging.batch.size is not set or if the value applies to all messages in the batch.
recommended: Only if span represents operation on a single message.
- ref: net.peer.name
note: >
This should be the IP/hostname of the broker (or other network-level peer) this specific message is sent to/received from.
Expand Down Expand Up @@ -117,7 +121,7 @@ groups:
attributes:
- ref: messaging.destination.name
requirement_level:
conditionally_required: If the value applies to all messages in the batch.
conditionally_required: If one message is being published or if the value applies to all messages in the batch.
- id: destination.kind
type:
allow_custom_values: false
Expand All @@ -143,7 +147,7 @@ groups:
An example would be a destination name involving a user name or product id.
Although the destination name in this case is of high cardinality,
the underlying template is of low cardinality and can be effectively
used for grouping and searching spans.
used for grouping and aggregation.
examples: ['/customers/{customerId}']
- id: destination.temporary
type: boolean
Expand All @@ -155,7 +159,6 @@ groups:
requirement_level:
conditionally_required: If value is `true`. When missing, the value is assumed to be `false`.
brief: 'A boolean that is true if the message destination is anonymous (could be unnamed or have auto-generated name).'

- id: messaging.producer.synchronous
prefix: messaging
type: span
Expand Down Expand Up @@ -204,16 +207,22 @@ groups:
If available. Instrumentations MUST NOT use `messaging.source.name` as template
unless low-cardinality of source name is guaranteed.
examples: ['/customers/{customerId}']
note: >
Source names could be constructed from templates.
An example would be a source name involving a user name or product id.
Although the source name in this case is of high cardinality,
the underlying template is of low cardinality and can be effectively
used for grouping and aggregation.
- id: source.temporary
type: boolean
requirement_level:
recommended: when supported by messaging system and only if the source is temporary. If missing, assumed to be false.
brief: 'denotes that the source is a temporary source and might not exist anymore after messages are processed'
brief: 'A boolean that is true if the message source is temporary and might not exist anymore after messages are processed.'
- id: source.anonymous
type: boolean
requirement_level:
recommended: when supported by messaging system and only if the source is anonymous. If missing, assumed to be false.
brief: 'denotes that the source is an anonymous source (could be unnamed or have auto-generated name)'
brief: 'A boolean that is true if the message source is anonymous (could be unnamed or have auto-generated name).'

- id: messaging.consumer.synchronous
prefix: messaging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ added as a link to the span. This means the span may have as many links as messa
- [`faas.trigger`][faas]] MUST be set to `pubsub`.
- [`messaging.operation`](../messaging.md) MUST be set to `process`.
- [`messaging.system`](../messaging.md) MUST be set to `AmazonSQS`.
- [`messaging.destination_kind`](../messaging.md#messaging-attributes) MUST be set to `queue`.
- [`messaging.destination.kind` or `messaging.source.kind`](../messaging.md#messaging-attributes) MUST be set to `queue`.

### SQS Message

Expand All @@ -136,7 +136,7 @@ added as a link to the span.
- [`faas.trigger`][faas] MUST be set to `pubsub`.
- [`messaging.operation`](../messaging.md#messaging-attributes) MUST be set to `process`.
- [`messaging.system`](../messaging.md#messaging-attributes) MUST be set to `AmazonSQS`.
- [`messaging.destination_kind`](../messaging.md#messaging-attributes) MUST be set to `queue`.
- [`messaging.destination.kind` or `messaging.source.kind`](../messaging.md#messaging-attributes) MUST be set to `queue`.

Other [Messaging attributes](../messaging.md#messaging-attributes) SHOULD be set based on the available information in the SQS message
event.
Expand Down Expand Up @@ -219,13 +219,15 @@ Function F: | Span ProcBatch |
| SpanKind | `PRODUCER` | `PRODUCER` | `CONSUMER` | `CONSUMER` | `CONSUMER` |
| Status | `Ok` | `Ok` | `Ok` | `Ok` | `Ok` |
| `messaging.system` | `AmazonSQS` | `AmazonSQS` | `AmazonSQS` | `AmazonSQS` | `AmazonSQS` |
| `messaging.destination` | `Q` | `Q` | `Q` | `Q` | `Q` |
| `messaging.destination_kind` | `queue` | `queue` | `queue` | `queue` | `queue` |
| `messaging.destination.name` | `Q` | `Q` | | | |
| `messaging.source.name` | | | `Q` | `Q` | `Q` |
| `messaging.destination.kind` | `queue` | `queue` | | | |
| `messaging.source.kind` | | | `queue` | `queue` | `queue` |
| `messaging.operation` | | | `process` | `process` | `process` |
| `messaging.message.id` | | | | `"a1"` | `"a2"` |

Note that if Span Prod1 and Span Prod2 were sent to different queues, Span ProcBatch would not have
`messaging.destination` set as it would correspond to multiple destinations.
`messaging.source.name` set as it would correspond to multiple sources.

The above requires user code change to create `Span Proc1` and `Span Proc2`. In Java, the user would inherit from
[TracingSqsMessageHandler][] instead of Lambda's standard `RequestHandler` to enable them. Otherwise these two spans
Expand Down
Loading

0 comments on commit 747411a

Please sign in to comment.