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

Add resource attributes as metric labels #314

Merged
merged 3 commits into from
Mar 28, 2024

Conversation

psx95
Copy link
Contributor

@psx95 psx95 commented Mar 25, 2024

Feature Addition

  • Adds user configurable option to attach service.name, service.namespace and service.id resource attributes to metric labels.
  • This can be disabled by passing the provided NO_RESOURCE_ATTRIBUTES as the resource filter to the MetricConfiguration object.
  • The default metric configuration has been changed to use the DEFAULT_RESOURCE_ATTRIBUTES_FILTER.

Note: This is similar to how the Google Cloud Monitoring go exporter works.

Testing

  • When running the auto-instrumentation-example, service_name appears under metric labels on GCP console with the expected value.
  • When running the metric export example, service_name appears with unknown_resource since the example does not include resource detection.

Deprecation

  • Deprecates the current publicly available AggregateByLabelMetricTimeSeriesBuilder constructor in favor of one that also accepts a resource attribute filter in form of a predicate. The existing constructor uses the NO_RESOURCE_ATTRIBUTES to keep it in-line with the existing functionality.

fixes #313

@psx95 psx95 marked this pull request as ready for review March 25, 2024 16:24
@psx95 psx95 requested a review from a team as a code owner March 25, 2024 16:24
@psx95 psx95 requested review from jsuereth and dashpole March 25, 2024 16:24
@psx95 psx95 merged commit b9b8c09 into GoogleCloudPlatform:main Mar 28, 2024
18 checks passed
@psx95 psx95 deleted the metric-attribute-filter branch March 28, 2024 15:32
lqiu96 pushed a commit to googleapis/sdk-platform-java that referenced this pull request Apr 17, 2024
…rces-support to v0.28.0 (#2649)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[com.google.cloud.opentelemetry:detector-resources-support](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java)
| `0.27.0` -> `0.28.0` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.cloud.opentelemetry:detector-resources-support/0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.cloud.opentelemetry:detector-resources-support/0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.cloud.opentelemetry:detector-resources-support/0.27.0/0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.cloud.opentelemetry:detector-resources-support/0.27.0/0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>GoogleCloudPlatform/opentelemetry-operations-java
(com.google.cloud.opentelemetry:detector-resources-support)</summary>

###
[`v0.28.0`](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/releases/tag/v0.28.0)

[Compare
Source](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/compare/v0.27.0...v0.28.0)

#### Release Highlights

- Add support for `CreateServiceTimeseries` in metrics exporter in
[#&#8203;318](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/issues/318).
- Add resource attributes as metrics labels by providing a Predicate
based filter to control which resource attributes end up as metric
labels in
[#&#8203;314](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/issues/314),
[#&#8203;319](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/issues/319).

#### What's Changed

- Add Readme for detector-resources-support module by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#282
- Copy instrumentation quickstart out of java-docs-samples by
[@&#8203;aabmass](https://togithub.com/aabmass) in
[GoogleCloudPlatform/opentelemetry-operations-java#283
- Enable snippet-bot by [@&#8203;aabmass](https://togithub.com/aabmass)
in
[GoogleCloudPlatform/opentelemetry-operations-java#284
- Quota project fix by [@&#8203;aabmass](https://togithub.com/aabmass)
in
[GoogleCloudPlatform/opentelemetry-operations-java#286
- Use logstash-logback-encoder version that works with spring boot 2 by
[@&#8203;aabmass](https://togithub.com/aabmass) in
[GoogleCloudPlatform/opentelemetry-operations-java#285
- Update instrumentation quickstart README links by
[@&#8203;aabmass](https://togithub.com/aabmass) in
[GoogleCloudPlatform/opentelemetry-operations-java#287
- Make examples/instrumentation-quickstart a standalone gradle build by
[@&#8203;aabmass](https://togithub.com/aabmass) in
[GoogleCloudPlatform/opentelemetry-operations-java#289
- Add CI for examples/instrumentation-quickstart by
[@&#8203;aabmass](https://togithub.com/aabmass) in
[GoogleCloudPlatform/opentelemetry-operations-java#290
- Test against java 11 by
[@&#8203;aabmass](https://togithub.com/aabmass) in
[GoogleCloudPlatform/opentelemetry-operations-java#293
- Update TraceTranslator.java by
[@&#8203;WadeGulbrandsen](https://togithub.com/WadeGulbrandsen) in
[GoogleCloudPlatform/opentelemetry-operations-java#296
- feat: simplify logging in instrumentation quickstart by
[@&#8203;dashpole](https://togithub.com/dashpole) in
[GoogleCloudPlatform/opentelemetry-operations-java#298
- Update Gradle to v8.6 by [@&#8203;psx95](https://togithub.com/psx95)
in
[GoogleCloudPlatform/opentelemetry-operations-java#300
- Replace resource detector with upstream detector by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#301
- Update links to the upstream detector by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#302
- Add OTLP trace with ADC example by
[@&#8203;damemi](https://togithub.com/damemi) in
[GoogleCloudPlatform/opentelemetry-operations-java#297
- Update auto-exporter readme by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#304
- Add tests to verify OTel integration using in-memory exporter by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#306
- Add GH action step to test shadowJar by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#309
- Add missing GOOGLE_CLOUD_QUOTA_PROJECT environment variable to compose
file by [@&#8203;aabmass](https://togithub.com/aabmass) in
[GoogleCloudPlatform/opentelemetry-operations-java#311
- Update instrumentation quickstart to new region tag name by
[@&#8203;aabmass](https://togithub.com/aabmass) in
[GoogleCloudPlatform/opentelemetry-operations-java#312
- Update instrumentation-quickstart README by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#315
- Add resource attributes as metric labels by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#314
- Update resource detection sample by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#317
- Make setResourceAttributesFilter public by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#319
- Add support for createServiceTimeSeries by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#318
- Disable release for gcp-resource-detector by
[@&#8203;psx95](https://togithub.com/psx95) in
[GoogleCloudPlatform/opentelemetry-operations-java#321

#### New Contributors

- [@&#8203;WadeGulbrandsen](https://togithub.com/WadeGulbrandsen) made
their first contribution in
[GoogleCloudPlatform/opentelemetry-operations-java#296
- [@&#8203;damemi](https://togithub.com/damemi) made their first
contribution in
[GoogleCloudPlatform/opentelemetry-operations-java#297

**Full Changelog**:
GoogleCloudPlatform/opentelemetry-operations-java@v0.27.0...v0.28.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/googleapis/sdk-platform-java).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMDEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjMwMS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Service name does not appear in metric labels when using auto-instrumentation
3 participants