Skip to content

Should event fields be part of the global attribute registry? #505

@martinkuba

Description

@martinkuba

This issue is intended as a discussion about the approach of defining event fields.

Background

Events are a new concept in OpenTelemetry that is in the process of being defined. An event will consist of a name and a body (payload). The name will be represented as the event.name attribute. The body payload will typically consist of a collection of fields (name/value pairs). An event may also have additional attributes that are separate from the body.

The discussion about field names in this issue refers to fields that are part of the event body, not the additional attributes. Additional attributes will follow the same rules as attributes on spans.

Discussion

Should fields in the event body be defined in the global attributes registry?

Here is an example event representing a browser page load (from this PR). The field names are not namespaced and their definition would be only in the scope of this specific event.

{
	"attributes": {
		"event.name": "browser.page_view" 
	},
	"body": {
		"referrer": "",
		"type": "",
		"title": "",
		"url": "",
	}
}

Pros:

  • shorter names
  • simpler to define (because they would be vetted only by experts familiar with the event, no discussion necessary how these fit in the global registry)
  • global registry will not be polluted with many one-off attributes

Cons:

  • some fields would be duplicated
  • definition of event fields is handled differently than attributes

Fields defined in the attribute registry

If the fields for the same event were defined in the registry, they could hypothetically look like this:

{
	"browser.document.referrer": "",
	"browser.page.type": "",
	"browser.page.title": "",
	"url.full": "",
}

Note that both url.full is an existing attribute that is re-used in this event. However, the browser.document.referrer also contains a full URL, but must have a different name here to distinguish from page URL and also to provide the meaning of the field.

Pros:

  • consistent with how metrics use attributes
  • field names could be reused without duplicating definition of the format and content

Cons:

  • there might be many fields in the registry that are used only once
    • this might make the registry harder to manage
    • might make it harder to define payloads of new events
  • larger payload size on the wire

Hybrid

There is a third option where an event payload could contain both fields defined only for the specific event and attributes from the global registry.

{
	"referrer": "",
	"type": "",
	"title": "",
	"url.full": "", 
}

Event fields defined externally

There might be cases when it's better to not define the content of a payload in OpenTelemetry semantic conventions, but instead link to an external definition. An example of this might be the data from the W3C ResourceTiming API. In this case, if the field definitions were duplicated in the attributes registry, they may get out of sync with the external definition.

If fields defined externally are used in the event body, they would not be namespaced.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions