-
Notifications
You must be signed in to change notification settings - Fork 936
[Logs] Add optional Ergonomic API #4741
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
3f414f0
62a752d
99bb74a
8139964
56f27f8
d3f5fb6
4e5a198
fe8c5fe
b10da75
0bb6e78
3f62fd0
9ad04f2
d42e679
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -143,15 +143,22 @@ Given the above state of the logging space we took the following approach: | |||||
| OpenTelemetry log data model. OpenTelemetry Collector can read such logs and | ||||||
| translate them to OpenTelemetry log data model. | ||||||
|
|
||||||
| - OpenTelemetry defines a Logs API | ||||||
| for [emitting LogRecords](./api.md#emit-a-logrecord). It is provided for | ||||||
| library authors to build [log appender](../glossary.md#log-appender--bridge), | ||||||
| - OpenTelemetry defines a [Logs API](./api.md) | ||||||
| for [emitting LogRecords](./api.md#emit-a-logrecord). It is primarily provided | ||||||
| for library authors to build [log appenders](../glossary.md#log-appender--bridge), | ||||||
| which use the API to bridge between existing logging libraries and the | ||||||
| OpenTelemetry log data model. Existing logging libraries generally provide | ||||||
| a much richer set of features than what is defined in OpenTelemetry. | ||||||
| It is NOT a goal of OpenTelemetry to ship a feature-rich logging library. | ||||||
| Yet, the Logs API can also be used directly if one prefers to couple the code | ||||||
| to it instead of using a bridged logging library. | ||||||
| OpenTelemetry log data model. The Logs API can also be used directly by | ||||||
| applications, which is particularly important for: | ||||||
|
|
||||||
| - **Instrumentation libraries** to avoid coupling to a particular logging library. | ||||||
| - **Emitting structured logs and events** following [semantic conventions](https://opentelemetry.io/docs/specs/semconv/), | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this is possible with logging libraries too. So may be specify that "this is the case when an existing logging library does not allow structure log or ability to specify event name"/similar.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed b10da75 |
||||||
| - **Scenarios requiring direct control** over log emission without | ||||||
| intermediary logging frameworks. | ||||||
|
|
||||||
| Note that existing logging libraries generally provide a much richer set of | ||||||
| features than what is defined in OpenTelemetry. Yet, languages may provide | ||||||
| an [ergonomic API](./api.md#ergonomic-api) for better developer experience | ||||||
| when using it directly. | ||||||
|
|
||||||
| - OpenTelemetry defines an [SDK](./sdk.md) implementation of the [API](./api.md), | ||||||
| which enables configuration of [processing](./sdk.md#logrecordprocessor) | ||||||
|
|
@@ -375,17 +382,30 @@ application startup. | |||||
|
|
||||||
| These are greenfield developments. OpenTelemetry provides recommendations and | ||||||
| best practices about how to emit logs (along with traces and metrics) from these | ||||||
| applications. For applicable languages and frameworks the auto-instrumentation | ||||||
| or simple configuration of a logging library to use an OpenTelemetry log appender | ||||||
| will still be the easiest way to emit context-enriched logs. As | ||||||
| already described earlier we provide extensions to some popular logging | ||||||
| libraries languages to support the manual instrumentation cases. The extensions | ||||||
| will support the inclusion of the trace context in the logs and allow to send | ||||||
| logs using OTLP protocol to the backend or to the Collector, bypassing the need | ||||||
| to have the logs represented as text files. Emitted logs are automatically | ||||||
| augmented by application-specific resource context (e.g. process id, programming | ||||||
| language, logging library name and version, etc). Full correlation across all | ||||||
| context dimensions will be available for these logs. | ||||||
| applications. | ||||||
|
|
||||||
| Applications have several options for emitting logs: | ||||||
|
|
||||||
| 1. **Using existing logging libraries with OpenTelemetry log appenders**: For | ||||||
| applicable languages and frameworks, auto-instrumentation or simple | ||||||
| configuration of a logging library to use an OpenTelemetry log appender will | ||||||
| be the easiest way to emit context-enriched logs. As already described earlier, | ||||||
| we provide extensions to some popular logging libraries to support manual | ||||||
| instrumentation cases. The extensions support the inclusion of the trace | ||||||
| context in the logs and allow sending logs via OTLP protocol to the backend | ||||||
| or to the Collector, bypassing the need to have the logs represented as text | ||||||
| files. | ||||||
|
|
||||||
| 2. **Using the OpenTelemetry Logs API directly**: Applications can use the | ||||||
| [Logs API](./api.md) directly to emit structured logs and events. This approach | ||||||
| works well for emitting logs following [semantic conventions](https://opentelemetry.io/docs/specs/semconv/) | ||||||
| and enables easier reuse of attributes used across different signals. Note | ||||||
| that a language can provide a more convenient [ergonomic API](./api.md#ergonomic-api). | ||||||
|
|
||||||
| Regardless of the approach, emitted logs are automatically augmented by | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it depends on the configuration, right?
Suggested change
|
||||||
| application-specific resource context (e.g. process id, programming language, | ||||||
| logging library name and version, etc). Full correlation across all context | ||||||
| dimensions will be available for these logs. | ||||||
|
|
||||||
| This is how a typical new application uses OpenTelemetry API, SDK and the | ||||||
| existing log libraries: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ aliases: [bridge-api] | |||||||||
|
|
||||||||||
| # Logs API | ||||||||||
|
|
||||||||||
| **Status**: [Stable](../document-status.md) | ||||||||||
| **Status**: [Stable](../document-status.md), except where otherwise specified | ||||||||||
|
|
||||||||||
| <details> | ||||||||||
| <summary>Table of Contents</summary> | ||||||||||
|
|
@@ -23,6 +23,7 @@ aliases: [bridge-api] | |||||||||
| * [Enabled](#enabled) | ||||||||||
| - [Optional and required parameters](#optional-and-required-parameters) | ||||||||||
| - [Concurrency requirements](#concurrency-requirements) | ||||||||||
| - [Ergonomic API](#ergonomic-api) | ||||||||||
| - [References](#references) | ||||||||||
|
|
||||||||||
| <!-- tocstop --> | ||||||||||
|
|
@@ -35,7 +36,8 @@ which use this API to bridge between existing logging libraries and the | |||||||||
| OpenTelemetry log data model. | ||||||||||
|
|
||||||||||
| The Logs API can also be directly called by instrumentation libraries | ||||||||||
| as well as instrumented libraries or applications. | ||||||||||
| as well as instrumented libraries or applications. However, languages are also | ||||||||||
| free to provide a more [ergonomic API](#ergonomic-api) for direct usage. | ||||||||||
|
|
||||||||||
| The Logs API consist of these main components: | ||||||||||
|
|
||||||||||
|
|
@@ -167,6 +169,20 @@ specific guarantees and safeties. | |||||||||
|
|
||||||||||
| **Logger** - all methods are safe to be called concurrently. | ||||||||||
|
|
||||||||||
| ## Ergonomic API | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we probably don't need a new section just to document something obvious (IMHO) to each language implementations. Languages were always free to offer extra helpers for all sort of things, and I think that is not prohibited in the spec.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to highlight a few points:
Would you prefer we:
I'm open to alternatives that achieve the clarity goal while addressing your concern about documenting the "obvious."
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My preference is : C
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am fine with C. Let's see wait for more feedback.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also updated the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During today's Spec SIG meeting it seemed that the attendees preference was: A |
||||||||||
|
|
||||||||||
| **Status**: [Development](../document-status.md) | ||||||||||
|
|
||||||||||
| Languages MAY additionally provide a more ergonomic and convenient logging API | ||||||||||
| that it is better suited for direct usage by instrumentation libraries, | ||||||||||
| instrumented libraries, and applications. | ||||||||||
|
Comment on lines
+176
to
+178
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: just more concise suggestion that avoid repeating all possible API callers
Suggested change
|
||||||||||
|
|
||||||||||
| The ergonomic API SHOULD make it easier to emit logs and events following the | ||||||||||
| [log semantics](https://opentelemetry.io/docs/specs/semconv/general/logs/) | ||||||||||
| and the [event semantics](https://opentelemetry.io/docs/specs/semconv/general/events/). | ||||||||||
|
Comment on lines
+180
to
+182
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm not sure about all these places that mention log semantic conventions since we're only planning to define semantic conventions for events is the idea that the ergonomic api is just for semantic conventions? or also for classical logging (e.g. templates, parameter substitution, etc), or limited to events + structured logging? |
||||||||||
|
|
||||||||||
| The design of the ergonomic API SHOULD be idiomatic for its language. | ||||||||||
|
|
||||||||||
| ## References | ||||||||||
|
|
||||||||||
| - [OTEP0150 Logging Library SDK Prototype Specification](../../oteps/logs/0150-logging-library-sdk.md) | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree with "primarily provided" due to its importance for other things stated below
but maybe "was primarily designed" or something similar?