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

[processor/spanmetrics] Support for specifying Resource Attributes on metrics generated from traces #6717

Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f5553a1
starts initial work on optional resource attributes config to span me…
Tenaria Dec 13, 2021
f186407
adds test to check metric length when copying resources
Tenaria Dec 13, 2021
3206a11
adds changelog and fixes tests
Tenaria Dec 13, 2021
3da4719
Merge branch 'main' into OBC-256-Resource-Attributes-Merge-Upstream
Tenaria Dec 13, 2021
945a6d1
fix tests
Tenaria Dec 13, 2021
fc62eab
remove empty new line
Tenaria Dec 13, 2021
07b5ad3
updates changelog
Tenaria Dec 13, 2021
5782cb0
add accidentally removed comment back in
Tenaria Dec 13, 2021
e2eb41d
revert variable name change and fix comment
Tenaria Dec 13, 2021
321c6e2
revert variable name cahnge
Tenaria Dec 13, 2021
fb0561c
adds test to ensure ordering of keys used for aggregation
Tenaria Dec 13, 2021
80ebf64
fixes lock held; optimise for loop; add parallel in test; add comments
Tenaria Dec 13, 2021
19775dc
reverse conditions to simplify code
Tenaria Dec 13, 2021
8c2d38e
update tests to use defined constant instrumentationLibraryName
Tenaria Dec 13, 2021
cbbf532
Merge branch 'main' into OBC-256-Resource-Attributes-Merge-Upstream
chenzhihao Jan 4, 2022
91c8b7d
update the logic of method updateCallMetrics
chenzhihao Jan 5, 2022
068a1bd
fix tests
chenzhihao Jan 5, 2022
18f20d0
add todos
chenzhihao Jan 5, 2022
4d370ad
add todos
chenzhihao Jan 5, 2022
024a122
Merge branch 'main' into OBC-256-Resource-Attributes-Merge-Upstream
chenzhihao Jan 5, 2022
7561f97
fix lint
chenzhihao Jan 5, 2022
62e892f
fix lint
chenzhihao Jan 5, 2022
d8edfda
remove resourceAttrList
chenzhihao Jan 5, 2022
d175a4e
Update "resource_attributes"
chenzhihao Jan 6, 2022
608a083
fix lint
chenzhihao Jan 6, 2022
a0519c0
remove duplicate p.resetExemplarData()
chenzhihao Jan 6, 2022
9772056
refactor how processor reset after every ConsumeTraces process
chenzhihao Jan 6, 2022
ae17b37
move keybuilder to a package
chenzhihao Jan 6, 2022
8ea124c
update comments
chenzhihao Jan 6, 2022
78c11f3
add copyright license
chenzhihao Jan 6, 2022
fbea55f
user defer for p.reset() so that downstream components can get data q…
chenzhihao Jan 6, 2022
3d6b4c1
gofmt
chenzhihao Jan 6, 2022
fd42b76
refactor how we use p.lock
chenzhihao Jan 6, 2022
7ed4b1c
gofmt
chenzhihao Jan 6, 2022
f676e46
added a set of unit tests to cover the excessive concurrent usage
chenzhihao Jan 7, 2022
4b71675
change the usage of the lock to make sure the processor can only be e…
chenzhihao Jan 7, 2022
494b483
Merge branch 'main' into OBC-256-Resource-Attributes-Merge-Upstream
chenzhihao Jan 7, 2022
38ebb2a
add comments; lint
chenzhihao Jan 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
## 🛑 Breaking changes 🛑

- `memcachedreceiver`: Update metric names (#6594)
- `spanmetricproccessor`: service.name attribute added as a default resource attribute instead of attribute in generated metrics (#6717)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to update the changelog, the maintainers will do this upon a new release

Copy link
Author

Choose a reason for hiding this comment

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

I saw in Zhihao's PR that there was a changelog added (see comment #6503 (review)). @MovieStoreGuy can you confirm whether we update the changelog or the maintainers do?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is fine for us to update the changelog, we have the greatest overall idea of what has changed so I think it makes sense to add it. However, If a maintainer says otherwise, I am also fine with it.

Copy link
Member

Choose a reason for hiding this comment

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

We would definitely prefer that you add a changelog entry, and there is CI automation that will complain if you don't! It generally makes it easier for us to prepare releases when we don't need to track down all the changes that have been made and think about how to describe them.


## 🚀 New components 🚀

## 🧰 Bug fixes 🧰

## 💡 Enhancements 💡

- `spanmetricproccessor`: Support specifying resource attributes to attach to metrics generated from traces (#6717)

## v0.41.0

## 🛑 Breaking changes 🛑
Expand Down
6 changes: 5 additions & 1 deletion processor/spanmetricsprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ latency_bucket{http_method="GET",http_status_code="200",label1="value1",operatio
```

Each metric will have _at least_ the following dimensions because they are common across all spans:
- Service name
- Operation
- Span kind
- Status code

Each metric will have _at least_ the following resource attributes because they are common across all spans:
- Service name

This processor lets traces to continue through the pipeline unmodified.

The following settings are required:
Expand All @@ -55,6 +57,8 @@ The following settings can be optionally configured:

If no `default` is provided, this dimension will be **omitted** from the metric.

- `resource_attributes`: the list of resource attributes to add together with the default resource attributes defined above. Each additional resource attributes is defined with a `name` which is looked up in the span's collection of resource attributes. If the `name`d resource attribute is missing in the span, the optional provided `default` is used. If no `default` is provided, this resource attribute will be **omitted** from the metric.

## Examples

The following is a simple example usage of the spanmetrics processor.
Expand Down
10 changes: 8 additions & 2 deletions processor/spanmetricsprocessor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"go.opentelemetry.io/collector/config"
)

// Dimension defines the dimension name and optional default value if the Dimension is missing from a span attribute.
// Dimension defines the key and optional default value if the key is missing from a span attribute.
type Dimension struct {
Name string `mapstructure:"name"`
Default *string `mapstructure:"default"`
Expand All @@ -38,11 +38,17 @@ type Config struct {
LatencyHistogramBuckets []time.Duration `mapstructure:"latency_histogram_buckets"`

// Dimensions defines the list of additional dimensions on top of the provided:
// - service.name
// - operation
// - span.kind
// - status.code
// The dimensions will be fetched from the span's attributes. Examples of some conventionally used attributes:
// https://github.com/open-telemetry/opentelemetry-collector/blob/main/model/semconv/opentelemetry.go.
Dimensions []Dimension `mapstructure:"dimensions"`

// ResourceAttributes defines the list of additional resource attributes to attach to metrics on top of the provided:
// - service.name
// These will be fetched from the span's resource attributes. For more details, see:
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md
// and https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md.
ResourceAttributes []Dimension `mapstructure:"resource_attributes"`
}
Loading