-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(sdk-metrics): implement metric reader metrics #6449
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
Open
anuraaga
wants to merge
17
commits into
open-telemetry:main
Choose a base branch
from
anuraaga:metrics-reader-metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5beee50
feat(metrics): implement metric reader metrics
anuraaga 26493a7
Chagnelog
anuraaga 301901f
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
anuraaga b68562e
generify
anuraaga a53bc2b
git add
anuraaga 041ff37
Lint
anuraaga 21ce20c
Fix
anuraaga 824ceff
Update test
anuraaga 143f841
Fix import
anuraaga 76e28bb
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
anuraaga e9eba34
Update
anuraaga feb4d21
Merge branch 'main' into metrics-reader-metrics
trentm 4cf52ca
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
anuraaga 052f9df
Remove setMeterProvider from public API
anuraaga bb6fbe7
Underscore
anuraaga b7dd71e
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
anuraaga 3f4c342
Fix merge
anuraaga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
experimental/packages/opentelemetry-exporter-prometheus/src/semconv.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /* | ||
| * This file contains a copy of unstable semantic convention definitions | ||
| * used by this package. | ||
| * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv | ||
| */ | ||
|
|
||
| /** | ||
| * Enum value "prometheus_http_text_metric_exporter" for attribute {@link ATTR_OTEL_COMPONENT_TYPE}. | ||
| * | ||
| * Prometheus metric exporter over HTTP with the default text-based format | ||
| * | ||
| * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. | ||
| */ | ||
| export const OTEL_COMPONENT_TYPE_VALUE_PROMETHEUS_HTTP_TEXT_METRIC_EXPORTER = | ||
| 'prometheus_http_text_metric_exporter' as const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import type { Attributes, Histogram, Meter } from '@opentelemetry/api'; | ||
| import { | ||
| ATTR_ERROR_TYPE, | ||
| ATTR_OTEL_COMPONENT_NAME, | ||
| ATTR_OTEL_COMPONENT_TYPE, | ||
| METRIC_OTEL_SDK_METRIC_READER_COLLECTION_DURATION, | ||
| } from '../semconv'; | ||
|
|
||
| const componentCounter = new Map<string, number>(); | ||
|
|
||
| /** | ||
| * Generates `otel.sdk.metric_reader.*` metrics. | ||
| * https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics/#metric-otelsdkmetric_readercollectionduration | ||
| */ | ||
| export class MetricReaderMetrics { | ||
| private readonly collectionDuration: Histogram; | ||
| private readonly standardAttrs: Attributes; | ||
|
|
||
| constructor(componentType: string, meter: Meter) { | ||
| const counter = componentCounter.get(componentType) ?? 0; | ||
| componentCounter.set(componentType, counter + 1); | ||
|
|
||
| this.standardAttrs = { | ||
| [ATTR_OTEL_COMPONENT_TYPE]: componentType, | ||
| [ATTR_OTEL_COMPONENT_NAME]: `${componentType}/${counter}`, | ||
| }; | ||
|
|
||
| this.collectionDuration = meter.createHistogram( | ||
| METRIC_OTEL_SDK_METRIC_READER_COLLECTION_DURATION, | ||
| { | ||
| unit: 's', | ||
| description: | ||
| 'The duration of the collect operation of the metric reader.', | ||
| advice: { | ||
| explicitBucketBoundaries: [], | ||
| }, | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| recordCollection(durationSecs: number, error: string | undefined) { | ||
| const attrs = error | ||
| ? { ...this.standardAttrs, [ATTR_ERROR_TYPE]: error } | ||
| : this.standardAttrs; | ||
| this.collectionDuration.record(durationSecs, attrs); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.