Skip to content

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

Merged
lalitb merged 11 commits intoopen-telemetry:mainfrom
lalitb:custom-id-generation
Apr 21, 2021
Merged

Support Custom span-id and trace-id generator#681
lalitb merged 11 commits intoopen-telemetry:mainfrom
lalitb:custom-id-generation

Conversation

@lalitb
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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

Comment thread sdk/test/trace/tracer_test.cc Outdated
Comment thread sdk/include/opentelemetry/sdk/trace/id_generator.h
Comment thread sdk/include/opentelemetry/sdk/trace/id_generator.h Outdated
Comment thread sdk/test/trace/tracer_test.cc Outdated
Comment thread sdk/include/opentelemetry/sdk/trace/tracer.h Outdated
Comment thread sdk/include/opentelemetry/sdk/trace/tracer_provider.h
@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