Skip to content

Commit

Permalink
draft: Initial Event body fields support
Browse files Browse the repository at this point in the history
- Take over Event type to represent both Log and Span events
- Add Body and Body Fields Support
- Fix and update forge tests
- Address initial review comments, add all existing events
  • Loading branch information
MSNev committed Jul 16, 2024
1 parent ece8753 commit 6f9a29a
Show file tree
Hide file tree
Showing 96 changed files with 18,118 additions and 1,667 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ just.zsh
.vscode/
.devcontainer/

# Visual Studio
.vs/

# Emacs
*~
\#*\#
Expand Down
54 changes: 54 additions & 0 deletions crates/weaver_forge/data/exception.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
groups:
- id: registry.exception
type: attribute_group
prefix: exception
brief: >
This document defines the shared attributes used to
report a single exception associated with a span or log.
attributes:
- id: type
type: string
stability: stable
brief: >
The type of the exception (its fully-qualified class name, if applicable).
The dynamic type of the exception should be preferred over the static type
in languages that support it.
examples: ["java.net.ConnectException", "OSError"]
- id: message
type: string
stability: stable
brief: The exception message.
examples: ["Division by zero", "Can't convert 'int' object to str implicitly"]
- id: stacktrace
type: string
stability: stable
brief: >
A stacktrace as a string in the natural representation for the language runtime.
The representation is to be determined and documented by each language SIG.
examples: 'Exception in thread "main" java.lang.RuntimeException: Test exception\n
at com.example.GenerateTrace.methodB(GenerateTrace.java:13)\n
at com.example.GenerateTrace.methodA(GenerateTrace.java:9)\n
at com.example.GenerateTrace.main(GenerateTrace.java:5)'
- id: escaped
type: boolean
stability: stable
brief: >
SHOULD be set to true if the exception event is recorded at a point where
it is known that the exception is escaping the scope of the span.
note: |-
An exception is considered to have escaped (or left) the scope of a span,
if that span is ended while the exception is still logically "in flight".
This may be actually "in flight" in some languages (e.g. if the exception
is passed to a Context manager's `__exit__` method in Python) but will
usually be caught at the point of recording the exception in most languages.
It is usually not possible to determine at the point where an exception is thrown
whether it will escape the scope of a span.
However, it is trivial to know that an exception
will escape, if one checks for an active exception just before ending the span,
as done in the [example for recording span exceptions](https://opentelemetry.io/docs/specs/semconv/exceptions/exceptions-spans/#recording-an-exception).
It follows that an exception may still escape the scope of the span
even if the `exception.escaped` attribute was not set or set to false,
since the event might have been recorded at a time where it was not
clear whether the exception will escape.
140 changes: 70 additions & 70 deletions crates/weaver_forge/data/mobile-events.yaml
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
groups:
- id: ios.lifecycle.events
- id: device.app.lifecycle
stability: experimental
type: event
prefix: ios
name: device.app.lifecycle
brief: >
This event represents an occurrence of a lifecycle transition on the iOS platform.
attributes:
- id: state
stability: experimental
requirement_level: "required"
note: >
The iOS lifecycle states are defined in the [UIApplicationDelegate documentation](https://developer.apple.com/documentation/uikit/uiapplicationdelegate#1656902),
and from which the `OS terminology` column values are derived.
brief: >
This attribute represents the state the application has transitioned into at the occurrence of the event.
type:
allow_custom_values: false
members:
- id: active
value: 'active'
brief: >
The app has become `active`. Associated with UIKit notification `applicationDidBecomeActive`.
- id: inactive
value: 'inactive'
brief: >
The app is now `inactive`. Associated with UIKit notification `applicationWillResignActive`.
- id: background
value: 'background'
brief: >
The app is now in the background.
This value is associated with UIKit notification `applicationDidEnterBackground`.
- id: foreground
value: 'foreground'
brief: >
The app is now in the foreground.
This value is associated with UIKit notification `applicationWillEnterForeground`.
- id: terminate
value: 'terminate'
brief: >
The app is about to terminate. Associated with UIKit notification `applicationWillTerminate`.
- id: android.lifecycle.events
type: event
prefix: android
name: device.app.lifecycle
brief: >
This event represents an occurrence of a lifecycle transition on the Android platform.
attributes:
- id: state
stability: experimental
requirement_level: required
brief: >
This attribute represents the state the application has transitioned into at the occurrence of the event.
note: >
The Android lifecycle states are defined in [Activity lifecycle callbacks](https://developer.android.com/guide/components/activities/activity-lifecycle#lc),
and from which the `OS identifiers` are derived.
type:
allow_custom_values: false
members:
- id: created
value: 'created'
brief: >
Any time before Activity.onResume() or, if the app has no Activity, Context.startService()
has been called in the app for the first time.
- id: background
value: 'background'
brief: >
Any time after Activity.onPause() or, if the app has no Activity,
Context.stopService() has been called when the app was in the foreground state.
- id: foreground
value: 'foreground'
brief: >
Any time after Activity.onResume() or, if the app has no Activity,
Context.startService() has been called when the app was in either the created or background states.
This event represents an occurrence of a lifecycle transition on Android or iOS platform.
note: >
This event identifies the fields that are common to all lifecycle events for android and iOS using
the `android.state` and `ios.state` fields. The `android.state` and `ios.state` attributes are
mutually exclusive.
body:
fields:
- id: ios.state
stability: experimental
requirement_level:
conditionally_required: if and only if `os.name` is `ios`
note: >
The iOS lifecycle states are defined in the [UIApplicationDelegate documentation](https://developer.apple.com/documentation/uikit/uiapplicationdelegate#1656902),
and from which the `OS terminology` column values are derived.
brief: >
This attribute represents the state the application has transitioned into at the occurrence of the event.
type:
allow_custom_values: false
members:
- id: active
value: 'active'
brief: >
The app has become `active`. Associated with UIKit notification `applicationDidBecomeActive`.
- id: inactive
value: 'inactive'
brief: >
The app is now `inactive`. Associated with UIKit notification `applicationWillResignActive`.
- id: background
value: 'background'
brief: >
The app is now in the background.
This value is associated with UIKit notification `applicationDidEnterBackground`.
- id: foreground
value: 'foreground'
brief: >
The app is now in the foreground.
This value is associated with UIKit notification `applicationWillEnterForeground`.
- id: terminate
value: 'terminate'
brief: >
The app is about to terminate. Associated with UIKit notification `applicationWillTerminate`.
- id: android.state
stability: experimental
requirement_level:
conditionally_required: if and only if `os.name` is `android`
brief: >
This attribute represents the state the application has transitioned into at the occurrence of the event.
note: >
The Android lifecycle states are defined in [Activity lifecycle callbacks](https://developer.android.com/guide/components/activities/activity-lifecycle#lc),
and from which the `OS identifiers` are derived.
type:
allow_custom_values: false
members:
- id: created
value: 'created'
brief: >
Any time before Activity.onResume() or, if the app has no Activity, Context.startService()
has been called in the app for the first time.
- id: background
value: 'background'
brief: >
Any time after Activity.onPause() or, if the app has no Activity,
Context.stopService() has been called when the app was in the foreground state.
- id: foreground
value: 'foreground'
brief: >
Any time after Activity.onResume() or, if the app has no Activity,
Context.startService() has been called when the app was in either the created or background states.
28 changes: 28 additions & 0 deletions crates/weaver_forge/data/registry-client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
groups:
- id: registry.client
prefix: client
type: attribute_group
brief: >
These attributes may be used to describe the client in a connection-based network interaction
where there is one side that initiates the connection (the client is the side that initiates the connection).
This covers all TCP network interactions since TCP is connection-based and one side initiates the
connection (an exception is made for peer-to-peer communication over TCP where the "user-facing" surface of the
protocol / API doesn't expose a clear notion of client and server).
This also covers UDP network interactions where one side initiates the interaction, e.g. QUIC (HTTP/3) and DNS.
attributes:
- id: address
stability: stable
type: string
brief: "Client address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name."
note: >
When observed from the server side, and when communicating through an intermediary, `client.address` SHOULD represent
the client address behind any intermediaries, for example proxies, if it's available.
examples: ['client.example.com', '10.1.2.80', '/tmp/my.sock']
- id: port
stability: stable
type: int
brief: Client port number.
examples: [65123]
note: >
When observed from the server side, and when communicating through an intermediary, `client.port` SHOULD represent
the client port behind any intermediaries, for example proxies, if it's available.
148 changes: 148 additions & 0 deletions crates/weaver_forge/data/registry-gen_ai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
groups:
- id: registry.gen_ai
prefix: gen_ai
type: attribute_group
brief: >
This document defines the attributes used to describe telemetry in the context of Generative Artificial Intelligence (GenAI) Models requests and responses.
attributes:
- id: system
stability: experimental
type:
members:
- id: openai
stability: experimental
value: "openai"
brief: 'OpenAI'
- id: vertex_ai
stability: experimental
value: "vertex_ai"
brief: 'Vertex AI'
- id: anthropic
stability: experimental
value: "anthropic"
brief: 'Anthropic'
- id: cohere
stability: experimental
value: "cohere"
brief: 'Cohere'
brief: The Generative AI product as identified by the client or server instrumentation.
note: |
The `gen_ai.system` describes a family of GenAI models with specific model identified
by `gen_ai.request.model` and `gen_ai.response.model` attributes.
The actual GenAI product may differ from the one identified by the client.
For example, when using OpenAI client libraries to communicate with Mistral, the `gen_ai.system`
is set to `openai` based on the instrumentation's best knowledge.
For custom model, a custom friendly name SHOULD be used.
If none of these options apply, the `gen_ai.system` SHOULD be set to `_OTHER`.
examples: 'openai'
- id: request.model
stability: experimental
type: string
brief: The name of the GenAI model a request is being made to.
examples: 'gpt-4'
- id: request.max_tokens
stability: experimental
type: int
brief: The maximum number of tokens the model generates for a request.
examples: [100]
- id: request.temperature
stability: experimental
type: double
brief: The temperature setting for the GenAI request.
examples: [0.0]
- id: request.top_p
stability: experimental
type: double
brief: The top_p sampling setting for the GenAI request.
examples: [1.0]
tag: llm-generic-request
- id: request.top_k
stability: experimental
type: double
brief: The top_k sampling setting for the GenAI request.
examples: [1.0]
- id: request.stop_sequences
stability: experimental
type: string[]
brief: List of sequences that the model will use to stop generating further tokens.
examples: ['forest', 'lived']
- id: request.frequency_penalty
stability: experimental
type: double
brief: The frequency penalty setting for the GenAI request.
examples: [0.1]
- id: request.presence_penalty
stability: experimental
type: double
brief: The presence penalty setting for the GenAI request.
examples: [0.1]
- id: response.id
stability: experimental
type: string
brief: The unique identifier for the completion.
examples: ['chatcmpl-123']
- id: response.model
stability: experimental
type: string
brief: The name of the model that generated the response.
examples: ['gpt-4-0613']
- id: response.finish_reasons
stability: experimental
type: string[]
brief: Array of reasons the model stopped generating tokens, corresponding to each generation received.
examples: ['stop']
- id: usage.input_tokens
stability: experimental
type: int
brief: The number of tokens used in the GenAI input (prompt).
examples: [100]
- id: usage.output_tokens
stability: experimental
type: int
brief: The number of tokens used in the GenAI response (completion).
examples: [180]
- id: token.type
stability: experimental
type:
members:
- id: input
stability: experimental
value: "input"
brief: 'Input tokens (prompt, input, etc.)'
- id: completion
stability: experimental
value: "output"
brief: 'Output tokens (completion, response, etc.)'
brief: The type of token being counted.
examples: ['input', 'output']
- id: prompt
stability: experimental
type: string
brief: The full prompt sent to the GenAI model.
note: It's RECOMMENDED to format prompts as JSON string matching [OpenAI messages format](https://platform.openai.com/docs/guides/text-generation)
examples: ["[{'role': 'user', 'content': 'What is the capital of France?'}]"]
- id: completion
stability: experimental
type: string
brief: The full response received from the GenAI model.
note: It's RECOMMENDED to format completions as JSON string matching [OpenAI messages format](https://platform.openai.com/docs/guides/text-generation)
examples: ["[{'role': 'assistant', 'content': 'The capital of France is Paris.'}]"]
- id: operation.name
stability: experimental
type:
members:
- id: chat
value: "chat"
brief: 'Chat completion operation such as [OpenAI Chat API](https://platform.openai.com/docs/api-reference/chat)'
stability: experimental
- id: text_completion
value: "text_completion"
brief: 'Text completions operation such as [OpenAI Completions API (Legacy)](https://platform.openai.com/docs/api-reference/completions)'
stability: experimental
brief: The name of the operation being performed.
note: >
If one of the predefined values applies, but specific system uses a different name it's RECOMMENDED to document it in the semantic
conventions for specific GenAI system and use system-specific name in the instrumentation.
If a different name is not documented, instrumentation libraries SHOULD use applicable predefined value.
Loading

0 comments on commit 6f9a29a

Please sign in to comment.