Skip to content

Conversation

DylanRussell
Copy link
Contributor

@DylanRussell DylanRussell commented Jul 9, 2025

Description

Move botocore from the deprecated events API to the logs API.

Type of change

Please delete options that are not relevant.

  • [x ] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I've updated the existing unit tests to all pass.

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • [ x] No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

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

@DylanRussell DylanRussell requested a review from a team as a code owner July 9, 2025 18:36
@DylanRussell
Copy link
Contributor Author

Updated dependencies to require opentelemetry-api >= 1.35, I think this can be merged now.

Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

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

Thanks and nice to see this moving along

@DylanRussell
Copy link
Contributor Author

ACtually before this goes in I think we need to update the SDK Logger to attach the resource to the LogRecord like the SDK EventLogger does: https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py#L654-L764

@tammy-baylis-swi
Copy link
Contributor

ACtually before this goes in I think we need to update the SDK Logger to attach the resource to the LogRecord like the SDK EventLogger does: https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py#L654-L764

Trying to follow. Is this related to Logging SDK vs Events SDK emit to init LogRecord with resource?

@DylanRussell
Copy link
Contributor Author

Yes. Event SDK emit adds resource, logging SDK does not. Logging SDK should do it, and there should be no SDK Log record (that's sort of tangentially related, the SDK logger expects an SDK log record when it should expect an API log record which has no resource on it)

@aabmass
Copy link
Member

aabmass commented Sep 30, 2025

@DylanRussell is this blocked on releasing open-telemetry/opentelemetry-python#4737?

Please resolve the merge conflict when you have a chance

attributes=attributes,
body=self._to_body_dict(),
**event_kwargs,
context=get_current(),
Copy link
Contributor

@xrmx xrmx Oct 7, 2025

Choose a reason for hiding this comment

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

I think instead we should set the span in context in the callers that needs it with:

from opentelemetry.trace.propagation import set_span_in_context

ctx = set_span_in_context(span, context.get_current())

and pass the context instead of trace_id, span_id, trace_flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@emdneto emdneto Oct 7, 2025

Choose a reason for hiding this comment

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

@DylanRussell the span_ctx = span.get_span_context() returns SpanContext object: tests pass with

+            from opentelemetry.trace.propagation import set_span_in_context
+            from opentelemetry.context import get_current
             # this path is used by streaming apis, in that case we are already out of the span
             # context so need to add the span context manually
-            span_ctx = span.get_span_context()
-            logger.emit(choice.to_choice_event(context=span_ctx))
+            ctx = set_span_in_context(span, get_current())
+            logger.emit(choice.to_choice_event(context=ctx))

span_ctx = span.get_span_context()
event_logger.emit(
logger.emit(
choice.to_choice_event(
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I think we should put the span in context and pass the context instead of the 3 deprecated params.

]
dependencies = [
"opentelemetry-api ~= 1.30",
"opentelemetry-api >= 1.37",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"opentelemetry-api >= 1.37",
"opentelemetry-api ~= 1.37",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants