-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[cmd/telemetrygen] Export telemetrygen functions for testing #37044
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
[cmd/telemetrygen] Export telemetrygen functions for testing #37044
Conversation
… `Start` with the appropriate config
…rygen-funcs-for-tests
…rygen-funcs-for-tests
This goes hand in hand with #37003 in order to help own and maintain this API. I read about chloggen, but haven't used it before so I copied the template and made a version manually. I hope I did that properly. |
…rygen-funcs-for-tests
…rygen-funcs-for-tests
…rygen-funcs-for-tests
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #37044 +/- ##
==========================================
- Coverage 79.60% 79.57% -0.03%
==========================================
Files 2250 2250
Lines 211890 211951 +61
==========================================
- Hits 168676 168668 -8
- Misses 37540 37608 +68
- Partials 5674 5675 +1 ☔ View full report in Codecov by Sentry. |
Interestingly much of the code stated as not covered in the patch is covered in the e2e tests, I suspect that they don't contribute to the coverage since it's technically a different Go module? |
@mx-psi, @codeboten, sorry to ping both of you, but if you have a moment in your day I'd love to get your thoughts on this implementation. I did what I could to create a sane first API to maintain and use. Any suggestions are welcome! 😄 I did consider using Start(
WithEndpoint("localhost:1234"),
WithRunDuration(5 * time.Second),
) But I thought it wouldn't give much more flexibility than just: mc := metrics.NewConfig()
mc.Endpoint = "localhost:1234"
mc.RunDuration = 5 * time.Second
err := metrics.Start(mc) Which was simpler to implement and support |
CI runner failure, but things seem to be running alright. Interestingly I don't have permissions to re-run the failed jobs. |
…telemetrygen-funcs-for-tests
…rygen-funcs-for-tests
f28d928
to
9c590e0
Compare
/easycla |
/easycla |
…rygen-funcs-for-tests
@codeboten Sorry to probe you on this, Just hoping to get your eyes on it since it's been requested by @mx-psi as well. |
oh Thank you! |
…rygen-funcs-for-tests
There appears to be an unrelated CI failure, @dmitryax is there a recommended way for users without permissions to kick the action again other than am empty commit? |
oh I see this issue is on main 😅 |
…rygen-funcs-for-tests
…rygen-funcs-for-tests
…rygen-funcs-for-tests
…rygen-funcs-for-tests
@mx-psi you're amazing thank you! |
…lemetry#37044) #### Description This PR addresses open-telemetry#36984 in order to open up telemetrygen to be used by golang tests and generate varying amounts of telemetry in code to support use cases which don't rely on external tools. The following major changes were made to clear the footprint for how this API can be used: 1. Moved `metrics`, `traces`, and `logs` under `pkg` instead of internal. 2. Unexported the `run` function for each test suite so the entrypoint is only the `Start` function 3. Moved config defaults from pflags into a `SetDefaults` function which is exported alongside `NewConfig` for changed packages in order for users to get the same sane defaults as if run from the command line. 4. Adjusted the pflags to use the existing default values rather than duplicate their own removing default config duplication 5. Added E2E tests for Metrics and Logs and adjusted Traces to use the new API so it stays consistent. 6. Adjusted log and metric exporter instantiation slightly due to a race condition with an `err` variable which was only caught by the new E2E tests. #### Testing Added to the E2E tests to ensure consistent API specs.
…lemetry#37044) #### Description This PR addresses open-telemetry#36984 in order to open up telemetrygen to be used by golang tests and generate varying amounts of telemetry in code to support use cases which don't rely on external tools. The following major changes were made to clear the footprint for how this API can be used: 1. Moved `metrics`, `traces`, and `logs` under `pkg` instead of internal. 2. Unexported the `run` function for each test suite so the entrypoint is only the `Start` function 3. Moved config defaults from pflags into a `SetDefaults` function which is exported alongside `NewConfig` for changed packages in order for users to get the same sane defaults as if run from the command line. 4. Adjusted the pflags to use the existing default values rather than duplicate their own removing default config duplication 5. Added E2E tests for Metrics and Logs and adjusted Traces to use the new API so it stays consistent. 6. Adjusted log and metric exporter instantiation slightly due to a race condition with an `err` variable which was only caught by the new E2E tests. #### Testing Added to the E2E tests to ensure consistent API specs.
Description
This PR addresses #36984 in order to open up telemetrygen to be used by golang tests and generate varying amounts of telemetry in code to support use cases which don't rely on external tools.
The following major changes were made to clear the footprint for how this API can be used:
metrics
,traces
, andlogs
underpkg
instead of internal.run
function for each test suite so the entrypoint is only theStart
functionSetDefaults
function which is exported alongsideNewConfig
for changed packages in order for users to get the same sane defaults as if run from the command line.
err
variable which was only caught by the new E2E tests.Testing
Added to the E2E tests to ensure consistent API specs.