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

Introduce new semantic conventions for CloudEvents #1978

Merged
merged 38 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1040881
Introduce semantic conventions for CloudEvents
joaopgrassi Sep 29, 2021
0223450
Update changelog
joaopgrassi Sep 29, 2021
f82fef8
Change wording to reflect the scope of this document
joaopgrassi Oct 4, 2021
86e4e4e
PR suggestions
joaopgrassi Oct 5, 2021
a1051c3
Remove section of not covered scenarios
joaopgrassi Oct 5, 2021
6d3cf0a
Fix lint errors
joaopgrassi Oct 5, 2021
0d7cdec
Move changelog into unreleased section
arminru Oct 15, 2021
a37ac6e
Adding spans to cloudevents spec (#17)
lmolkova Oct 22, 2021
8b362c5
Update TOC
joaopgrassi Oct 22, 2021
1a30c69
Update CloudEvents spec based on meeting discussion (#18)
lmolkova Nov 10, 2021
b513e29
Update specification/trace/semantic_conventions/cloudevents.md
joaopgrassi Nov 11, 2021
5fb9b49
Merge remote-tracking branch 'upstream/main' into semconv-cloudevents
joaopgrassi Nov 18, 2021
bbdc4f6
Clarify paragraph around cloud events libraries
joaopgrassi Nov 18, 2021
ce87cf0
Change a bit paragraph around cloud events libraries
joaopgrassi Nov 18, 2021
8e94701
Merge branch 'main' into semconv-cloudevents
joaopgrassi Nov 23, 2021
0cf35f4
Merge branch 'main' into semconv-cloudevents
joaopgrassi Nov 30, 2021
8c0cb2a
Merge remote-tracking branch 'upstream/main' into semconv-cloudevents
joaopgrassi Dec 20, 2021
95523cf
PR suggestions
joaopgrassi Dec 20, 2021
be229c8
Remove instrumentation section
joaopgrassi Dec 28, 2021
5d6ac5c
Merge branch 'main' into semconv-cloudevents
joaopgrassi Jan 13, 2022
9835f3a
Merge branch 'main' into semconv-cloudevents
joaopgrassi Jan 14, 2022
01a0dac
Merge branch 'main' into semconv-cloudevents
joaopgrassi Jan 25, 2022
bd684c5
Merge remote-tracking branch 'upstream/main' into semconv-cloudevents
joaopgrassi Jan 27, 2022
87ca073
Merge remote-tracking branch 'upstream/main' into semconv-cloudevents
joaopgrassi Feb 7, 2022
24c8ec0
Merge branch 'main' into semconv-cloudevents
arminru Feb 8, 2022
7128a5c
Mark required attributes
joaopgrassi Feb 16, 2022
b17e28f
Add clarification about CloudEvents
joaopgrassi Feb 16, 2022
dc6a944
Improve wording
joaopgrassi Feb 16, 2022
56426fe
Move reasoning + diagrams from comments to the document
joaopgrassi Feb 25, 2022
c7f2272
Merge remote-tracking branch 'upstream/main' into semconv-cloudevents
joaopgrassi Feb 25, 2022
2063130
Merge remote-tracking branch 'upstream/main' into semconv-cloudevents
joaopgrassi Mar 7, 2022
ca0da3d
Apply suggestions from code review
joaopgrassi Mar 10, 2022
704059f
Update links to point to the new CloudEvents spec
joaopgrassi Mar 10, 2022
7ec8648
Address PR comments
joaopgrassi Mar 10, 2022
7cf0a88
Improve diagram spaces a bit
joaopgrassi Mar 10, 2022
5d2585d
Improve diagram spaces a bit
joaopgrassi Mar 10, 2022
714543a
Address PR comments
joaopgrassi Mar 10, 2022
eaa8ff6
Merge branch 'main' into semconv-cloudevents
arminru Mar 10, 2022
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
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ release.

### Semantic Conventions

- Prohibit usage of retired names in semantic conventions.
([#2191](https://github.com/open-telemetry/opentelemetry-specification/pull/2191))
- Add `device.manufacturer` to describe mobile device manufacturers.
([2100](https://github.com/open-telemetry/opentelemetry-specification/pull/2100))
- Changed `rpc.system` to an enum (allowing custom values), and changed the
`rpc.system` value for .NET WCF from `wcf` to `dotnet_wcf`.
([#2377](https://github.com/open-telemetry/opentelemetry-specification/pull/2377))
- Define JavaScript runtime semantic conventions.
([#2290](https://github.com/open-telemetry/opentelemetry-specification/pull/2290))
- Add semantic conventions for [CloudEvents](https://cloudevents.io).
([#1978](https://github.com/open-telemetry/opentelemetry-specification/pull/1978))

Expand Down
8 changes: 4 additions & 4 deletions semantic_conventions/trace/cloudevents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ groups:
attributes:
- id: event_id
type: string
required: always
brief: >
The [event_id](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#id) uniquely identifies the event.
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
note: >
Producers MUST ensure that event_source + event_id is unique for each distinct event.
If a duplicate event is re-sent (e.g. due to a network error) it MAY have the same id.
Consumers MAY assume that Events with identical event_source and event_id are duplicates.
examples: ['123e4567-e89b-12d3-a456-426614174000', '0001']
- id: event_source
type: string
required: always
brief: >
The [source](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#source-1) identifies the context in which an event happened.
examples: ['https://github.com/cloudevents', '/cloudevents/spec/pull/123', 'my-service' ]
- id: event_spec_version
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
type: string
required: always
brief: >
The [version of the CloudEvents specification](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#specversion) which the event uses.
examples: '1.0'
- id: event_type
type: string
required: always
brief: >
The [event_type](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#type) contains a value describing the type of event related to the originating occurrence.
examples: ['com.github.pull_request.opened', 'com.example.object.deleted.v2']
Expand Down
179 changes: 145 additions & 34 deletions specification/trace/semantic_conventions/cloudevents.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,152 @@

**Status**: [Experimental](../../document-status.md)

This specification defines semantic conventions for [CloudEvents](https://cloudevents.io/).
It covers creation, processing and context propagation between producer and consumer.
It does not cover transport aspects of publishing and receiving cloud events.
<!-- Re-generate TOC with `markdown-toc --no-first-h1 -i` -->

## Overview
<!-- toc -->

To be individually traceable, each CloudEvent has to have its own trace context.
The trace context is populated in the event using the
[CloudEvents Distributed Tracing Extension](https://github.com/cloudevents/spec/blob/v1.0.1/extensions/distributed-tracing.md).
- [Definitions](#definitions)
- [Overview](#overview)
- [Conventions](#conventions)
* [Spans](#spans)
+ [Creation](#creation)
+ [Processing](#processing)
* [Attributes](#attributes)

Once the trace context is set on the event, it MUST not be modified.
<!-- tocstop -->

<!-- Re-generate TOC with `markdown-toc --no-first-h1 -i` -->
## Definitions

<!-- toc -->
From the
[CloudEvents specification:](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#overview)
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

- [Spans](#spans)
* [Creation](#creation)
* [Processing](#processing)
- [Instrumentation](#instrumentation)
- [Attributes](#attributes)
> CloudEvents is a specification for describing event data in common formats
to provide interoperability across services, platforms and systems.
>

<!-- tocstop -->
For more information on the concepts, terminology and background of CloudEvents
consult the
[CloudEvents Primer](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/primer.md)
document.

## Overview

A CloudEvent can be sent directly from producer to consumer.
For such a scenario, the traditional parent-child trace model works well.
However, CloudEvents are also used in distributed systems where an event
can go through many [hops](https://en.wikipedia.org/wiki/Hop_(networking))
until it reaches a consumer. In this scenario, the traditional parent-child
trace model is not sufficient to produce a meaningful trace.

Consider the following scenario:

```
+----------+ +--------------+
| Producer | ---------------> | Intermediary |
+----------+ +--------------+
|
|
|
v
+----------+ +----------+
| Consumer | <----------------- | Queue |
+----------+ +----------+
```

With the traditional parent-child trace model, the above scenario would produce
two traces, completely independent from each other. It is not possible to
correlate a producer with a consumer(s).
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

```
+---------------------------------------------------+
| Trace 1 |
| |
| +---------------------------------------+ |
| | Send (auto-instr) | |
| +---------------------------------------+ |
| +------------------------------------+ |
| | Intermediary: Received (auto-instr)| |
| +------------------------------------+ |
| +------------------------------------+ |
| | Intermediary: Send (auto-instr) | |
| +------------------------------------+ |
| |
| Trace 2 |
| |
| +---------------------------------------+ |
| | Consumer: Receive (auto-instr) | |
| +---------------------------------------+ |
| |
+---------------------------------------------------+
```

This document defines semantic conventions to model the different stages
a CloudEvent can go through in a system, making it possible to create traces
that are meaningful and consistent. It covers creation, processing,
context propagation between producer and consumer(s) and attributes
to be added to spans.

With the proposed model, it is possible to have an overview of everything
that happened as the result of an event. One can, for example, answer the
following questions:

- What components in a system reacted to an event
- What further events were sent due to an incoming event
- Which event caused the exception

With the conventions in this document, the application scenario above would
produce a trace where it is possible to correlate a producer with a consumer(s):

```
+-------------------------------------------------------+
| Trace 1 |
| |
| +---------------------------------------+ |
| +---> | Create event | |
| | +---------------------------------------+ |
| | +---------------------------------------+ |
| | | Send (auto-instr) | |
| | +---------------------------------------+ |
| | +------------------------------------+ |
| | | Intermediary: Received (auto-instr)| |
| | +------------------------------------+ |
| | +------------------------------------+ |
| | | Intermediary: Send (auto-instr) | |
| |Link +------------------------------------+ |
| | |
| | |
| | |
| | Trace 2 |
| | |
| | +---------------------------------------+ |
| | | Consumer: Receive (auto-instr) | |
| | +---------------------------------------+ |
| | +-------------------------------------+ |
| +------ | Consumer: Process | |
| +-------------------------------------+ |
| |
+-------------------------------------------------------+
```

## Conventions

To achieve the trace above, it is necessary to capture the context of
the event creation so that when the CloudEvent reaches its destination(s), this
context can be continued. Each CloudEvent acts then as the medium of this
context propagation.

This document relies on the CloudEvents specification, which defines this
context propagation mechanism via the
[CloudEvents Distributed Tracing Extension](https://github.com/cloudevents/spec/blob/v1.0.1/extensions/distributed-tracing.md).
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
Once the trace context is set on the event
via the Distributed Tracing Extension, it MUST not be modified.

## Spans
The remainder of this section describes the semantic conventions for Spans
required to achieve the proposed trace.

### Creation
### Spans

#### Creation

Instrumentation SHOULD create a new span and populate the
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
[CloudEvents Distributed Tracing Extension](https://github.com/cloudevents/spec/blob/v1.0.1/extensions/distributed-tracing.md)
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -47,9 +166,10 @@ Distributed Tracing Extension already populated, instrumentation MUST NOT create
a span and MUST NOT modify the Distributed Tracing Extension on the event.

**Span name:** `CloudEvents Create <event_type>`

**Span kind:** PRODUCER
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

### Processing
#### Processing

When an instrumented library supports processing of a single CloudEvent,
instrumentation SHOULD create a new span to trace it.
Expand All @@ -58,28 +178,19 @@ Instrumentation SHOULD set the remote trace context from the
Distributed Tracing Extension as a link on the processing span.
arminru marked this conversation as resolved.
Show resolved Hide resolved

**Span name:** `CloudEvents Process <event_type>`
**Span kind:** CONSUMER

## Instrumentation

CloudEvents libraries SHOULD have built-in mechanisms to make the aforementioned
Span operations (creation, extraction, and injection of context into events)
transparent for application owners. When auto-instrumentation
is not feasible, CloudEvents libraries SHOULD offer such mechanisms in a form that
application owners can "plug in" to apply the Span operations above by themselves.
**Span kind:** CONSUMER

## Attributes
### Attributes

The following attributes are applicable to creation and processing Spans.

<!-- semconv cloudevents -->
| Attribute | Type | Description | Examples | Required |
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
|---|---|---|---|---|
| `cloudevents.event_id` | string | The [event_id](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#id) uniquely identifies the event. [1] | `123e4567-e89b-12d3-a456-426614174000`; `0001` | No |
| `cloudevents.event_source` | string | The [source](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#source-1) identifies the context in which an event happened. | `https://github.com/cloudevents`; `/cloudevents/spec/pull/123`; `my-service` | No |
| `cloudevents.event_spec_version` | string | The [version of the CloudEvents specification](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#specversion) which the event uses. | `1.0` | No |
| `cloudevents.event_type` | string | The [event_type](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#type) contains a value describing the type of event related to the originating occurrence. | `com.github.pull_request.opened`; `com.example.object.deleted.v2` | No |
| `cloudevents.event_id` | string | The [event_id](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#id) uniquely identifies the event. | `123e4567-e89b-12d3-a456-426614174000`; `0001` | Yes |
| `cloudevents.event_source` | string | The [source](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#source-1) identifies the context in which an event happened. | `https://github.com/cloudevents`; `/cloudevents/spec/pull/123`; `my-service` | Yes |
| `cloudevents.event_spec_version` | string | The [version of the CloudEvents specification](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#specversion) which the event uses. | `1.0` | Yes |
| `cloudevents.event_type` | string | The [event_type](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#type) contains a value describing the type of event related to the originating occurrence. | `com.github.pull_request.opened`; `com.example.object.deleted.v2` | Yes |
| `cloudevents.event_subject` | string | The [subject](https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#subject) of the event in the context of the event producer (identified by source). | `mynewfile.jpg` | No |

**[1]:** Producers MUST ensure that event_source + event_id is unique for each distinct event. If a duplicate event is re-sent (e.g. due to a network error) it MAY have the same id. Consumers MAY assume that Events with identical event_source and event_id are duplicates.
<!-- endsemconv -->