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

Export internal metrics using OTEL metrics #1425

Merged
merged 12 commits into from
Jan 15, 2025
Merged

Export internal metrics using OTEL metrics #1425

merged 12 commits into from
Jan 15, 2025

Conversation

marctc
Copy link
Contributor

@marctc marctc commented Dec 2, 2024

This PR adds the ability to exporter Beyla internal metrics for users that are using OpenTelemetry metrics.

Fixes #1211

docs/sources/configure/options.md Outdated Show resolved Hide resolved
docs/sources/configure/options.md Outdated Show resolved Hide resolved
Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

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

LGTM! Sweet!

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 4.13793% with 139 lines in your changes missing coverage. Please review.

Project coverage is 71.66%. Comparing base (da5252f) to head (5f1d101).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/export/otel/metrics_internal.go 0.00% 112 Missing ⚠️
pkg/components/beyla.go 30.00% 12 Missing and 2 partials ⚠️
pkg/beyla/config.go 0.00% 4 Missing and 2 partials ⚠️
pkg/internal/imetrics/imetrics.go 0.00% 5 Missing ⚠️
pkg/export/otel/metrics_net.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1425      +/-   ##
==========================================
- Coverage   72.19%   71.66%   -0.53%     
==========================================
  Files         194      195       +1     
  Lines       19239    19372     +133     
==========================================
- Hits        13889    13883       -6     
- Misses       4679     4814     +135     
- Partials      671      675       +4     
Flag Coverage Δ
integration-test 53.76% <4.13%> (-0.39%) ⬇️
k8s-integration-test 54.97% <4.13%> (-0.09%) ⬇️
oats-test 31.03% <3.44%> (-0.23%) ⬇️
unittests 47.48% <3.44%> (-0.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pkg/internal/imetrics/imetrics.go Outdated Show resolved Hide resolved
docs/sources/configure/options.md Outdated Show resolved Hide resolved
pkg/export/otel/metrics_internal.go Outdated Show resolved Hide resolved
@@ -5,9 +5,27 @@ import (
"context"
)

type InternalMetricsExporter string

const (
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of typing these as strings and bearing the overhead of passing them around and string comparison, I'd type them as uint8 or int and provide an UnmarshalTextimplementation that takes care of deserialising the string. See

and
func (b *TCBackend) UnmarshalText(text []byte) error {
for reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds like a good optimization. However, for sake of consistency I'd rather leave like this. Maybe open an issue to fix this everywhere in our code base?

Copy link
Contributor

Choose a reason for hiding this comment

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

Will do

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as this string comparison is done once at startup, I'd say that the overhead is negligible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed you are right. Although there's an extra hidden benefit with using UnmarshallText, albeit perhaps not that relevant/important, but worth noting: when it returns an error (for instance because the wrong input/option has been provided) it causes the program to fail very early in the process, before we start running validation code and what not:

time=2025-01-08T09:59:35.286-06:00 level=ERROR msg="wrong configuration" error="reading env vars: env: parse error on field \"TCBackend\" of type \"tcmanager.TCBackend\": invalid TCBakend value: 'foo'"

Just thought I'd mention it for the record.

@marctc marctc requested a review from a team as a code owner January 7, 2025 16:57
@@ -5,9 +5,27 @@ import (
"context"
)

type InternalMetricsExporter string

const (
Copy link
Contributor

Choose a reason for hiding this comment

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

As long as this string comparison is done once at startup, I'd say that the overhead is negligible.

@marctc marctc force-pushed the otel_internal_metrics branch from 7d19fdc to 5f1d101 Compare January 15, 2025 11:08
@marctc marctc merged commit 3c59816 into main Jan 15, 2025
14 of 15 checks passed
@marctc marctc deleted the otel_internal_metrics branch January 15, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export internal metrics using OTEL metrics
4 participants