Skip to content

feat(logs): implement log creation metric#4935

Open
anuraaga wants to merge 3 commits intoopen-telemetry:mainfrom
anuraaga:logger-metrics
Open

feat(logs): implement log creation metric#4935
anuraaga wants to merge 3 commits intoopen-telemetry:mainfrom
anuraaga:logger-metrics

Conversation

@anuraaga
Copy link
Contributor

Description

I am helping to implement SDK internal metrics

https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics/

This implements the metric for created logs. It is very similar to #4880 for spans.

/cc @xrmx to help with review

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@anuraaga anuraaga requested a review from a team as a code owner February 26, 2026 02:39
@xrmx xrmx moved this to Ready for review in @xrmx's Python PR digest Feb 26, 2026
@xrmx xrmx self-assigned this Feb 26, 2026
Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small nit but LGTM

instrumentation_scope=self._instrumentation_scope,
)

self._logger_metrics.emit_log()
Copy link
Contributor

@xrmx xrmx Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this on_emit as well? emit_log sounds like you are going to emit a new log more than it has been emitted.

formatter: Callable[
[ReadableLogRecord], str
] = lambda record: record.to_json() + linesep,
formatter: Callable[[ReadableLogRecord], str] = lambda record: (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a newer ruff installed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants