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

Fix broken spanmetrics counters after span producing service restart #29711

Merged
merged 18 commits into from
Dec 21, 2023

Conversation

portertech
Copy link
Contributor

@portertech portertech commented Dec 8, 2023

My spanmetrics counters (e.g. calls_total) break after restarting the span producing service.

For example:

Screenshot from 2023-12-06 11-39-57

I discovered that the resource key used for the calculated metrics was a map hash of the resource attributes. This worked fine for some instrumented services, however, other services include attributes like its process id etc. Restarting one of these services would result in a new hash and calculated resource metrics (in addition to the existing ones).

This pull-request filters the resource attributes used to produce the resource metrics key map hash. I am now able to restart services without breaking my counters.

don't include things like process pid etc.

Signed-off-by: Sean Porter <portertech@gmail.com>
Copy link
Member

@songy23 songy23 left a comment

Choose a reason for hiding this comment

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

Please add a changelog

Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Copy link
Contributor

@albertteoh albertteoh left a comment

Choose a reason for hiding this comment

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

Thanks! I think this might also be useful in limiting memory/cpu resources; which seems to be coming up as issues recently.

Added a couple of comments.

connector/spanmetricsconnector/connector.go Outdated Show resolved Hide resolved
connector/spanmetricsconnector/connector.go Outdated Show resolved Hide resolved
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Copy link
Contributor

@albertteoh albertteoh left a comment

Choose a reason for hiding this comment

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

Looks good overall! Just some nits.

Thanks for making it configurable by the way!

connector/spanmetricsconnector/config.go Show resolved Hide resolved
connector/spanmetricsconnector/connector.go Outdated Show resolved Hide resolved
connector/spanmetricsconnector/connector.go Outdated Show resolved Hide resolved
Copy link
Contributor

@albertteoh albertteoh left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@MovieStoreGuy MovieStoreGuy left a comment

Choose a reason for hiding this comment

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

Just some minor optimisations and clarification have behaviour, otherwise, seems reasonable to me.

connector/spanmetricsconnector/config.go Show resolved Hide resolved
connector/spanmetricsconnector/connector.go Outdated Show resolved Hide resolved
@MovieStoreGuy MovieStoreGuy added the ready to merge Code review completed; ready to merge by maintainers label Dec 18, 2023
@codeboten codeboten merged commit 4acf9f8 into open-telemetry:main Dec 21, 2023
85 checks passed
@github-actions github-actions bot added this to the next release milestone Dec 21, 2023
@portertech portertech deleted the spanmetrics-broken-count branch December 21, 2023 19:01
@portertech portertech restored the spanmetrics-broken-count branch January 8, 2024 19:01
djaglowski pushed a commit that referenced this pull request Jan 10, 2024
Added @portertech (me) to connector/spanmetrics codeowners.

Supporters: @djaglowski, @albertteoh 

Recent relevant PR:
#29711

Signed-off-by: Sean Porter <portertech@gmail.com>
cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this pull request Jan 10, 2024
…pen-telemetry#29711)

My spanmetrics counters (e.g. `calls_total`) break after restarting the
span producing service.

For example:

![Screenshot from 2023-12-06
11-39-57](https://github.com/open-telemetry/opentelemetry-collector-contrib/assets/149630/abea1b72-392b-4f1f-a403-644c4e356f3d)

I discovered that the resource key used for the calculated metrics was a
map hash of the resource attributes. This worked fine for some
instrumented services, however, other services include attributes like
its process id etc. Restarting one of these services would result in a
new hash and calculated resource metrics (in addition to the existing
ones).

This pull-request filters the resource attributes used to produce the
resource metrics key map hash. I am now able to restart services without
breaking my counters.

---------

Signed-off-by: Sean Porter <portertech@gmail.com>
Co-authored-by: Albert <26584478+albertteoh@users.noreply.github.com>
cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this pull request Jan 10, 2024
…ry#30401)

Added @portertech (me) to connector/spanmetrics codeowners.

Supporters: @djaglowski, @albertteoh 

Recent relevant PR:
open-telemetry#29711

Signed-off-by: Sean Porter <portertech@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connector/spanmetrics ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants