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

Events API implementation #4054

Merged
merged 35 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dae55a5
initial commit
soumyadeepm04 Jul 14, 2024
078d75c
lint
soumyadeepm04 Jul 14, 2024
7df9ed2
Merge branch 'main' into eventapi
soumyadeepm04 Jul 16, 2024
f028535
resolve comments
soumyadeepm04 Jul 19, 2024
722fb54
Merge branch 'eventapi' of https://github.com/soumyadeepm04/opentelem…
soumyadeepm04 Jul 19, 2024
0b3eec2
Merge branch 'main' into eventapi
xrmx Jul 22, 2024
32baf7c
Merge branch 'main' into eventapi
emdneto Jul 22, 2024
da611a8
updated CHANGELOG
soumyadeepm04 Jul 23, 2024
100826d
Merge branch 'eventapi' of https://github.com/soumyadeepm04/opentelem…
soumyadeepm04 Jul 23, 2024
79af742
Merge branch 'main' into eventapi
emdneto Jul 23, 2024
2d186bd
Merge branch 'main' into eventapi
soumyadeepm04 Jul 25, 2024
7a4db6c
initial full implementation
soumyadeepm04 Jul 27, 2024
a991447
Merge branch 'eventapi' of https://github.com/soumyadeepm04/opentelem…
soumyadeepm04 Jul 27, 2024
7111579
Merge branch 'main' into eventapi
soumyadeepm04 Jul 27, 2024
1115efc
lint
soumyadeepm04 Jul 27, 2024
a20d31e
Merge branch 'eventapi' of https://github.com/soumyadeepm04/opentelem…
soumyadeepm04 Jul 27, 2024
e328c9d
lint
soumyadeepm04 Jul 27, 2024
0d1dd73
lint
soumyadeepm04 Jul 27, 2024
bfe1fb0
rename file
soumyadeepm04 Jul 27, 2024
235eec5
lint
soumyadeepm04 Jul 27, 2024
f25db47
Merge branch 'main' into eventapi
lzchen Jul 30, 2024
cfc3792
fix comments
soumyadeepm04 Aug 13, 2024
5589341
Merge branch 'eventapi' of https://github.com/soumyadeepm04/opentelem…
soumyadeepm04 Aug 13, 2024
2ff0a4e
fix lint
soumyadeepm04 Aug 13, 2024
1742aaa
fix comments
soumyadeepm04 Aug 13, 2024
f597da6
fix lint
soumyadeepm04 Aug 13, 2024
c3642ed
fix lint
soumyadeepm04 Aug 13, 2024
e379cb4
Merge branch 'main' into eventapi
lzchen Aug 13, 2024
f5928e8
Merge branch 'main' into eventapi
xrmx Aug 19, 2024
3259a1b
Merge branch 'main' into eventapi
xrmx Aug 21, 2024
ad8244d
Update opentelemetry-api/src/opentelemetry/_events/__init__.py
soumyadeepm04 Aug 21, 2024
9e07117
fix attributes
soumyadeepm04 Aug 21, 2024
68831d3
Merge branch 'eventapi' of https://github.com/soumyadeepm04/opentelem…
soumyadeepm04 Aug 21, 2024
5b10d0b
fix lint
soumyadeepm04 Aug 21, 2024
2cf8bd9
Merge branch 'main' into eventapi
lzchen Aug 21, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Events API implementation
soumyadeepm04 marked this conversation as resolved.
Show resolved Hide resolved
([#4054](https://github.com/open-telemetry/opentelemetry-python/pull/4054))
- optional scope attributes for logger creation
([#4035](https://github.com/open-telemetry/opentelemetry-python/pull/4035))
- optional scope attribute for tracer creation
Expand Down
58 changes: 58 additions & 0 deletions opentelemetry-api/src/opentelemetry/_events/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from abc import ABC, abstractmethod
soumyadeepm04 marked this conversation as resolved.
Show resolved Hide resolved
from typing import Any, Optional

from opentelemetry._logs import LogRecord
from opentelemetry._logs.severity import SeverityNumber
from opentelemetry.context.context import Context
from opentelemetry.util.types import Attributes


class Event(LogRecord):

def __init__(
self,
name: str,
payload: Optional[Any] = None,
soumyadeepm04 marked this conversation as resolved.
Show resolved Hide resolved
lzchen marked this conversation as resolved.
Show resolved Hide resolved
attributes: Optional[Attributes] = None,
):
super().__init__(
body=payload, # type: ignore
attributes=attributes,
)
self.name = name


class EventLogger(ABC):
xrmx marked this conversation as resolved.
Show resolved Hide resolved

def __init__(
self,
name: str,
body: Optional[Any] = None,
timestamp: Optional[int] = None,
context: Optional[Context] = None,
severity_number: Optional[SeverityNumber] = None,
attributes: Optional[Attributes] = None,
):
self._name = name
self._body = body # type: ignore
self._timestamp = timestamp
self._context = context
self._severity_number = severity_number
self._attributes = attributes

@abstractmethod
def emit(self, event: "Event") -> None:
"""Emits a :class:`Event` representing an event."""


class EventLoggerProvider(ABC):

@abstractmethod
def get_event_logger(
self,
name: str,
version: Optional[str] = None,
schema_url: Optional[str] = None,
attributes: Optional[Attributes] = None,
) -> EventLogger:
"""Returns an EventLoggerProvider for use."""