Skip to content

Adding Resource to MetricRecord#1209

Merged
codeboten merged 10 commits intoopen-telemetry:masterfrom
codeboten:resource-in-metric-record
Oct 7, 2020
Merged

Adding Resource to MetricRecord#1209
codeboten merged 10 commits intoopen-telemetry:masterfrom
codeboten:resource-in-metric-record

Conversation

@codeboten
Copy link
Copy Markdown
Contributor

Description

Adding the Resource as a parameter to the Batcher (aka Processor see #1203). Not having the resource in the MetricRecord currently causes an issue retrieving resource information in the OTLP exporter.

Fixes #1208

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been update
  • Documentation has been updated

@codeboten codeboten marked this pull request as ready for review October 6, 2020 05:35
@codeboten codeboten requested a review from a team October 6, 2020 05:35
@codeboten codeboten changed the title WIP: Adding Resource to MetricRecord Adding Resource to MetricRecord Oct 6, 2020
labels = {"environment": "staging"}
aggregator = SumAggregator()
record = MetricRecord(metric, labels, aggregator)
record = MetricRecord(metric, labels, aggregator, meter.resource)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be good to have a test that tests to see if the resource created in the metric record matches the resource in the meterprovider.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the ConsoleMetricsExporter to show the resource and updated the test to validate it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be better to remove resource from Meter: codeboten#9

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The spec does specify that a Meter should bind an API with a resource: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/metrics/sdk.md#sdk-terminology, but I guess since we're not making use of the resource yet, it's ok to remove it here for now.

Copy link
Copy Markdown
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

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

CHANGELOG?

@codeboten
Copy link
Copy Markdown
Contributor Author

CHANGELOG?

Added it, not sure how I forgot it.

@codeboten codeboten requested a review from lzchen October 6, 2020 17:22
Copy link
Copy Markdown
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

Please take a look at this: codeboten#9

Copy link
Copy Markdown
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

LGTM 👍

self.instrumentation_info = instrumentation_info
self.processor = Processor(source.stateful)
self.resource = source.resource
self.processor = Processor(source.stateful, source.resource)
Copy link
Copy Markdown
Contributor

@lzchen lzchen Oct 6, 2020

Choose a reason for hiding this comment

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

Take a look at this comment. I believe we should actually decouple Tracer from TracerProvider, and equivalently, Meter from MeterProvider by removing the source attribute. We should be passing in configuration through the Provider into the constructor of both Tracer and Meter. resource would be one of those configurations. Not sure if you want to do this as part of this PR however.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It looks like issue #1181 already tracks this work, I'd rather do this as a follow up to this PR.

@codeboten codeboten requested a review from lzchen October 7, 2020 15:15
@codeboten codeboten merged commit 8d7cba0 into open-telemetry:master Oct 7, 2020
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
* chore: fixing zone from which to fork a new zone

* chore: adding tests for creating zone

Co-authored-by: Mayur Kale <mayurkale@google.com>
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.

Metrics SDK: The MetricRecord should have access to the resource

3 participants