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

Support Custom span-id and trace-id generator #681

Merged
merged 11 commits into from
Apr 21, 2021

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Apr 19, 2021

Fixes #677

Changes

  • Add abstract interface for a span-id and trace-id generation.
  • Convert existing logic for random span-id and trace-id as the default implementation for the above interface.
  • Modify TracerProvider and TracerContext constructor to support injecting the custom id generator.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team April 19, 2021 07:02
@codecov
Copy link

codecov bot commented Apr 19, 2021

Codecov Report

Merging #681 (5c9c35e) into main (ae060d1) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #681      +/-   ##
==========================================
+ Coverage   94.64%   94.67%   +0.02%     
==========================================
  Files         206      208       +2     
  Lines        9382     9407      +25     
==========================================
+ Hits         8880     8906      +26     
+ Misses        502      501       -1     
Impacted Files Coverage Δ
sdk/include/opentelemetry/sdk/trace/id_generator.h 100.00% <100.00%> (ø)
sdk/include/opentelemetry/sdk/trace/tracer.h 100.00% <100.00%> (ø)
sdk/src/trace/random_id_generator.cc 100.00% <100.00%> (ø)
sdk/src/trace/span.cc 88.88% <100.00%> (-0.70%) ⬇️
sdk/src/trace/tracer_context.cc 80.00% <100.00%> (+5.00%) ⬆️
sdk/src/trace/tracer_provider.cc 78.94% <100.00%> (+2.47%) ⬆️
sdk/test/trace/tracer_provider_test.cc 100.00% <100.00%> (ø)
sdk/test/trace/tracer_test.cc 100.00% <100.00%> (ø)
... and 1 more

Copy link
Contributor

@eyjohn eyjohn left a comment

Choose a reason for hiding this comment

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

Overall looks great to land, some minor nitpicks,

Minor question about constness

/**
* A Mock Custom Id Generator
*/
class MockIdGenerator : public IdGenerator
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Google Mock would be great to use here, I noticed we don't have it in the repo but EXPECT_CALL and return values can all be done in the test body which would be nice

sdk/test/trace/tracer_test.cc Outdated Show resolved Hide resolved
sdk/include/opentelemetry/sdk/trace/id_generator.h Outdated Show resolved Hide resolved
@lalitb lalitb merged commit 2e7594e into open-telemetry:main Apr 21, 2021
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.

Custom Trace and Span IDs Generation
4 participants