Skip to content

Commit

Permalink
Merge branch 'main' into opencensus_bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
reyang authored Sep 2, 2022
2 parents 393fa1d + f0c001e commit 4f9e105
Show file tree
Hide file tree
Showing 15 changed files with 434 additions and 216 deletions.
12 changes: 7 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ release.
([#2619](https://github.com/open-telemetry/opentelemetry-specification/pull/2619)).
- Clarify async instrument callback identity.
([#2538](https://github.com/open-telemetry/opentelemetry-specification/pull/2538)).
- Add `process.threads` host metric semantic convention.
([#2705](https://github.com/open-telemetry/opentelemetry-specification/pull/2705)).

### Logs

- Update log SDK to allow log processors to mutate log records
([#2681](https://github.com/open-telemetry/opentelemetry-specification/pull/2681)).
- Add experimental Events and Logs API specification
([#2676](https://github.com/open-telemetry/opentelemetry-specification/pull/2676))

### Resource

- Update the version of the W3C Baggage specification used for `OTEL_RESOURCE_ATTRIBUTES`.
Expand All @@ -46,9 +53,6 @@ release.
([#2618](https://github.com/open-telemetry/opentelemetry-specification/pull/2618))
- Change `faas.document.time` and `faas.time` level from `required` to `recommended`
([#2627](https://github.com/open-telemetry/opentelemetry-specification/pull/2627))
- Remove `direction` dimension, instead creating metrics with names reflecting those
dimensions.
([#2617](https://github.com/open-telemetry/opentelemetry-specification/pull/2617))
- Add `rpc.grpc.status_code` to RPC metric semantic conventions
([#2604](https://github.com/open-telemetry/opentelemetry-specification/pull/2604)).
- Add `http.*.*.size` metric semantic conventions for tracking size of requests
Expand All @@ -64,8 +68,6 @@ release.
([#2663](https://github.com/open-telemetry/opentelemetry-specification/pull/2663))
- Add `process.parent_pid` attribute for use in reporting parent process id (PID)
([#2691](https://github.com/open-telemetry/opentelemetry-specification/pull/2691)).
- Separate tcp/udp protocols for metric `system.network.connections`.
([#2675](https://github.com/open-telemetry/opentelemetry-specification/pull/2675))
- Add OpenSearch to db.system semantic conventions
([#2718](https://github.com/open-telemetry/opentelemetry-specification/pull/2718)).

Expand Down
86 changes: 0 additions & 86 deletions schemas/1.13.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,6 @@ file_format: 1.1.0
schema_url: https://opentelemetry.io/schemas/1.13.0
versions:
1.13.0:
metrics:
changes:
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.paging.operations
by_attribute: direction
metrics_from_attributes:
system.paging.operations.in: in
system.paging.operations.out: out
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.disk.io
by_attribute: direction
metrics_from_attributes:
system.disk.io.read: read
system.disk.io.write: write
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.disk.operations
by_attribute: direction
metrics_from_attributes:
system.disk.operations.read: read
system.disk.operations.write: write
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.disk.operation_time
by_attribute: direction
metrics_from_attributes:
system.disk.operation_time.read: read
system.disk.operation_time.write: write
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.disk.merged
by_attribute: direction
metrics_from_attributes:
system.disk.merged.read: read
system.disk.merged.write: write
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.network.dropped
by_attribute: direction
metrics_from_attributes:
system.network.dropped.receive: receive
system.network.dropped.transmit: transmit
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.network.packets
by_attribute: direction
metrics_from_attributes:
system.network.packets.receive: receive
system.network.packets.transmit: transmit
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.network.errors
by_attribute: direction
metrics_from_attributes:
system.network.errors.receive: receive
system.network.errors.transmit: transmit
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: system.network.io
by_attribute: direction
metrics_from_attributes:
system.network.io.receive: receive
system.network.io.transmit: transmit
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: process.disk.io
by_attribute: direction
metrics_from_attributes:
process.disk.io.read: read
process.disk.io.write: write
# https://github.com/open-telemetry/opentelemetry-specification/pull/2617
- split:
apply_to_metric: process.network.io
by_attribute: direction
metrics_from_attributes:
process.network.io.receive: receive
process.network.io.transmit: transmit
# https://github.com/open-telemetry/opentelemetry-specification/pull/2675
- split:
apply_to_metric: system.network.connections
by_attribute: protocol
metrics_from_attributes:
system.network.tcp.connections: tcp
system.network.udp.connections: udp
spans:
changes:
# https://github.com/open-telemetry/opentelemetry-specification/pull/2614
Expand Down
32 changes: 32 additions & 0 deletions semantic_conventions/logs/events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
groups:
- id: event
prefix: event
brief: >
This document defines attributes for Events represented using Log Records.
attributes:
- id: name
type: string
requirement_level: required
brief: >
The name identifies the event.
examples: ['click', 'exception']
- id: domain
brief: >
The domain identifies the context in which an event happened. An event name is unique only within a domain.
type:
allow_custom_values: true
members:
- id: browser
value: 'browser'
brief: 'Events from browser apps'
- id: device
value: 'device'
brief: 'Events from mobile apps'
- id: k8s
value: 'k8s'
brief: 'Events from Kubernetes'
requirement_level: required
note: |
An `event.name` is supposed to be unique only in the context of an
`event.domain`, so this allows for two events in different domains to
have same `event.name`, yet be unrelated events.
2 changes: 1 addition & 1 deletion specification/logs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ There are typically 2 ways to collect logs from these applications.
#### Via File or Stdout Logs

The first approach, assuming the logs are written to files or to standard
output, requires ability to read file logs, tail then, work correctly when log
output, requires ability to read file logs, tail them, work correctly when log
rotation is used, optionally also parse the logs to convert them into more
structured formats. Parings requires support for different parser types, which
can also be configured to parse custom formats as well as ability to add custom
Expand Down
145 changes: 145 additions & 0 deletions specification/logs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Events and Logs API Interface

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

<details>
<summary>Table of Contents</summary>

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

<!-- toc -->

- [Data Model](#data-model)
- [LoggerProvider](#loggerprovider)
* [LoggerProvider operations](#loggerprovider-operations)
+ [Get a Logger](#get-a-logger)
- [Logger](#logger)
* [Logger operations](#logger-operations)

<!-- tocstop -->

</details>

The Events and Logs API consist of these main classes:

* LoggerProvider is the entry point of the API. It provides access to Loggers.
* Logger is the class responsible for creating events and logs using Log records.

LoggerProvider/Logger are analogous to TracerProvider/Tracer.

```mermaid
graph TD
A[LoggerProvider] -->|Get| B(Logger)
B --> C(Event)
B --> D(Log)
```

## Data Model

The API creates Events and Logs using the `LogRecord` data model. See `LogRecord` [data model](data-model.md) for the list of fields.

## LoggerProvider

`Logger`s can be accessed with a `LoggerProvider`.

In implementations of the API, the LoggerProvider is expected to be the stateful
object that holds any configuration.

Normally, the LoggerProvider is expected to be accessed from a central place.
Thus, the API SHOULD provide a way to set/register and access a global default
LoggerProvider.

Notwithstanding any global LoggerProvider, some applications may want to or have
to use multiple LoggerProvider instances, e.g. to have different configuration
(like LogProcessors) for each (and consequently for the Loggers obtained
from them), or because it's easier with dependency injection frameworks. Thus,
implementations of LoggerProvider SHOULD allow creating an arbitrary number of
instances.

### LoggerProvider operations

The LoggerProvider MUST provide the following functions:

* Get a Logger

#### Get a Logger

This API MUST accept the following parameters:

- `name` (required): This name SHOULD uniquely identify the [instrumentation scope](../glossary.md#instrumentation-scope),
such as the [instrumentation library](../glossary.md#instrumentation-library)
(e.g. `io.opentelemetry.contrib.mongodb`), package, module or class name.
If an application or library has built-in OpenTelemetry instrumentation, both
[Instrumented library](../glossary.md#instrumented-library) and
[Instrumentation library](../glossary.md#instrumentation-library) may refer to
the same library. In that scenario, the `name` denotes a module name or component
name within that library or application. In case an invalid name
(null or empty string) is specified, a working Logger implementation MUST be
returned as a fallback rather than returning null or throwing an exception, its
`name` property SHOULD be set to an empty string, and a message reporting that
the specified value is invalid SHOULD be logged. A library implementing the
OpenTelemetry API may also ignore this name and return a default instance for
all calls, if it does not support "named" functionality (e.g. an implementation
which is not even observability-related). A LoggerProvider could also return a
no-op Logger here if application owners configure the SDK to suppress telemetry
produced by this library.
- `version` (optional): Specifies the version of the instrumentation scope if
the scope has a version (e.g. a library version). Example value: 1.0.0.
- `schema_url` (optional): Specifies the Schema URL that should be recorded in
the emitted telemetry.
- `event_domain` (optional): Specifies the domain for the events created, which
should be added as `event.domain` attribute of the instrumentation scope.
- `include_trace_context` (optional): Specifies whether the Trace Context should
automatically be passed on to the events and logs created by the Logger. This
SHOULD be true by default.
- `attributes` (optional): Specifies the instrumentation scope attributes to
associate with emitted telemetry.

Implementations MUST return different `Logger` instances when called repeatedly
with different values of parameters. Note that always returning a new `Logger`
instance is a valid implementation. The only exception to this rule is the no-op
`Logger`: implementations MAY return the same instance regardless of parameter
values.

Implementations MUST NOT require users to repeatedly obtain an Logger again with
the same name+version+schema_url+event_domain+include_trace_context+attributes
to pick up configuration changes. This can be achieved either by allowing to
work with an outdated configuration or by ensuring that new configuration
applies also to previously returned Loggers.

Note: This could, for example, be implemented by storing any mutable
configuration in the `LoggerProvider` and having `Logger` implementation objects
have a reference to the `LoggerProvider` from which they were obtained.
If configuration must be stored per-Logger (such as disabling a certain `Logger`),
the `Logger` could, for example, do a look-up with its name+version+schema_url+event_domain+include_trace_context+attributes
in a map in the `LoggerProvider`, or the `LoggerProvider` could maintain a registry
of all returned `Logger`s and actively update their configuration if it changes.

The effect of associating a Schema URL with a `Logger` MUST be that the telemetry
emitted using the `Logger` will be associated with the Schema URL, provided that
the emitted data format is capable of representing such association.

## Logger

The `Logger` is responsible for creating Events and Logs.

Note that `Logger`s should not be responsible for configuration. This should be
the responsibility of the `LoggerProvider` instead.

### Logger operations

The Logger MUST provide functions to:

- Create a `LogRecord`, representing an `Event` and emit it to the processing
pipeline.
- The API MUST accept an event name as a parameter. The event name provided
should be recorded as an attribute with key `event.name`. Care MUST be taken
by the implementation to not override or delete this attribute while the
`Event` is created to preserve its identity.
- Events require the `event.domain` attribute. The API MUST not allow creating
an event if the Logger instance doesn't have `event.domain` scope attribute.
- This function MAY be named `logEvent`.
- Create a `LogRecord` and emit it to the processing pipeline.
- This function MAY be named `logRecord`.
- This API is intended for use by Log Appenders, and SHOULD not be used by end
users or other instrumentation.
Loading

0 comments on commit 4f9e105

Please sign in to comment.