Skip to content

feat(opentelemetry-instrumentation-botocore): Instrument kinesis records#4364

Open
mosheshaham-dash0 wants to merge 5 commits intoopen-telemetry:mainfrom
mosheshaham-dash0:instrument-kinesis-records-v2
Open

feat(opentelemetry-instrumentation-botocore): Instrument kinesis records#4364
mosheshaham-dash0 wants to merge 5 commits intoopen-telemetry:mainfrom
mosheshaham-dash0:instrument-kinesis-records-v2

Conversation

@mosheshaham-dash0
Copy link
Copy Markdown

Description

This PR adds tracecontext to kinesis PutRecord requests by injecting them into the message payload.

Fixes # (issue)

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

ran manual testing and added unit testing

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

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

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

@mosheshaham-dash0 mosheshaham-dash0 changed the title Instrument kinesis records v2 feat(opentelemetry-instrumentation-botocore): Instrument kinesis records Mar 26, 2026
@lzchen lzchen moved this to Ready for review in Python PR digest Mar 26, 2026
cls._inject_span_into_entry(call_context.params)

@classmethod
def _inject_span_into_entry(cls, entry: MutableMapping[str, Any]):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This functionality should at the very least be opt-in. There is no guarantee that the user will be serializing data a JSON. Furthermore, from a performance/efficiency point of view, it is very wasteful to serialize JSON just to immediately deserialize it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

agree. introduced the ENABLE_KINESIS_INSTRUMENTATION env var. by default disabled.

################################################################################


class _KinesisOperation(abc.ABC):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't really see the value added here for introducing this ABC and the inheritance hierarchy, especially given that we are only instrumenting two operations here. In my opinion, this makes the implementation details much harder to reason about. Can we refactor this to just use a simple set of helper functions?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

actually, this pattern was copied from other instrumentations in the package, like sns, lambda, dynamodb. I don't think it's too complicated and i think it's better than instrumentations that don't use this pattern like bedrock.

################################################################################

_OPERATION_MAPPING: Dict[str, _KinesisOperation] = {
op.operation_name(): op
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems overkill, I would just explicitly list out the operations here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

you are right, i fixed it. (btw, this was copied from the sns.py insturmentation)

@herin049 herin049 moved this from Ready for review to Reviewed PRs that need fixes in Python PR digest Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

3 participants