-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(instrumentation-runtime-node)!: add prom-client-metrics (#2136)
- Loading branch information
1 parent
6234918
commit 80d0c74
Showing
21 changed files
with
2,291 additions
and
134 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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
16 changes: 16 additions & 0 deletions
16
plugins/node/instrumentation-runtime-node/src/consts/attributes.ts
This file contains 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,16 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export const ATTR_V8JS_HEAP_SPACE_NAME = 'heap.space.name'; |
This file contains 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,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { Histogram } from 'perf_hooks'; | ||
|
||
declare module 'node:perf_hooks' { | ||
interface IntervalHistogram extends Histogram { | ||
/** | ||
* Enables the update interval timer. Returns `true` if the timer was | ||
* started, `false` if it was already started. | ||
* @since v11.10.0 | ||
*/ | ||
enable(): boolean; | ||
|
||
/** | ||
* Disables the update interval timer. Returns `true` if the timer was | ||
* stopped, `false` if it was already stopped. | ||
* @since v11.10.0 | ||
*/ | ||
disable(): boolean; | ||
|
||
count: number; | ||
} | ||
} |
This file contains 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
48 changes: 48 additions & 0 deletions
48
plugins/node/instrumentation-runtime-node/src/metrics/baseCollector.ts
This file contains 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,48 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { MetricCollector } from '../types/metricCollector'; | ||
import { Meter } from '@opentelemetry/api'; | ||
import { RuntimeNodeInstrumentationConfig } from '../types'; | ||
|
||
export abstract class BaseCollector implements MetricCollector { | ||
protected _config: RuntimeNodeInstrumentationConfig = {}; | ||
|
||
protected namePrefix: string; | ||
|
||
protected constructor( | ||
config: RuntimeNodeInstrumentationConfig = {}, | ||
namePrefix: string | ||
) { | ||
this._config = config; | ||
this.namePrefix = namePrefix; | ||
} | ||
|
||
public disable(): void { | ||
this._config.enabled = false; | ||
this.internalDisable(); | ||
} | ||
|
||
public enable(): void { | ||
this._config.enabled = true; | ||
this.internalEnable(); | ||
} | ||
|
||
public abstract updateMetricInstruments(meter: Meter): void; | ||
|
||
protected abstract internalEnable(): void; | ||
|
||
protected abstract internalDisable(): void; | ||
} |
Oops, something went wrong.