opentelemetry-js
opentelemetry-js copied to clipboard
feat: browser support for exporter-trace-otlp-proto
Which problem is this PR solving?
Provide the option of exporting traces using protobuf from the browser. Previously this package only supported Node, since this package now uses protobuf-js it is possible to send protobuf from the browser.
Fixes #3118
TODOs
- [ ] Compression options
- [x] Add karma config for tests
- [ ] Add unit tests
- [x] Add example of using the proto exporter in the browser
- [x] Finish up tests listed below
Short description of the changes
- Added browser exporter for the proto exporter package
- Added browser exporter for trace proto exporter package
- Added example using the trace proto exporter package
Type of change
Please delete options that are not relevant.
- [x] New feature (non-breaking change which adds functionality)
- [x] 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
- [x] Send traces in the browser using the proto exporter
- [x] Node proto exporter still works as expected
- [x] Env variables are supported
- [x] Existing config is supported
Checklist:
- [ ] Followed the style guidelines of this project
- [ ] Unit tests have been added
- [ ] Documentation has been updated
Codecov Report
Merging #3208 (426f321) into main (5127371) will decrease coverage by
0.02%. The diff coverage isn/a.
:exclamation: Current head 426f321 differs from pull request most recent head 9429864. Consider uploading reports for the commit 9429864 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #3208 +/- ##
==========================================
- Coverage 93.80% 93.79% -0.02%
==========================================
Files 249 249
Lines 7640 7640
Branches 1589 1589
==========================================
- Hits 7167 7166 -1
- Misses 473 474 +1
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...-otlp-proto/src/platform/node/OTLPTraceExporter.ts | 100.00% <ø> (ø) |
|
| packages/opentelemetry-resources/src/Resource.ts | 100.00% <ø> (ø) |
|
| ...-trace-base/src/platform/node/RandomIdGenerator.ts | 87.50% <0.00%> (-6.25%) |
:arrow_down: |
@pichlermarc @legendecas @dyladan could one of you help check what the unit tests are failing for? I only see "Error: Process completed with exit code 3." at the end of each tests run, but it's not clear what error the process encountered. In my local setup I see failure in api/test/tree-shaking/tree-shaking.test.ts (even though this PR has made no changes to the api), but it's not clear if the unit tests in github CI are failing for the same reason. Thanks for looking into this.
@scheler I'll take a look at the CI problem.
@open-telemetry/javascript-approvers can you please review this PR?
I think it is fine to move the util function as a member method for the web, as the send function is accessing many members of the collector and not depends on external modules.
@legendecas I made this change.
@legendecas I made the suggested changes, please take a look.
@legendecas all the suggested changes are now complete, can you see if anything else is needed or approve? Thanks.
Thank you for working on this!
@open-telemetry/javascript-maintainers can you review and merge this PR? It has a few approvals already.