forked from open-telemetry/opentelemetry-demo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update metrics name
- Loading branch information
yanweili
committed
Nov 19, 2024
1 parent
dae9066
commit 12bc4af
Showing
7 changed files
with
110 additions
and
77 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# extra settings to be merged into OpenTelemetry Collector configuration | ||
# do not delete this file | ||
|
||
## Example configuration for sending data to your own OTLP HTTP backend | ||
## Note: the spanmetrics exporter must be included in the exporters array | ||
## if overriding the traces pipeline. | ||
## | ||
processors: | ||
resource: | ||
attributes: | ||
- key: service.instance.id | ||
value: otel-demo | ||
action: upsert | ||
|
||
# Replace the INSTANA_ENDPOINT, more information please refer to: | ||
# https://www.ibm.com/docs/en/instana-observability/current?topic=opentelemetry-sending-data-instana | ||
exporters: | ||
otlp/instana: | ||
endpoint: INSTANA_ENDPOINT | ||
tls: | ||
insecure: true | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
processors: [transform, batch, resource] | ||
exporters: [otlp, debug, spanmetrics, otlp/instana] | ||
metrics: | ||
receivers: [otlp, spanmetrics] | ||
processors: [batch, resource] | ||
exporters: [otlphttp/prometheus, debug, otlp/instana] | ||
logs: | ||
receivers: [otlp] | ||
processors: [batch, resource] | ||
exporters: [opensearch, debug] |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package main | ||
|
||
import ( | ||
"context" | ||
"math" | ||
"runtime" | ||
|
||
"go.opentelemetry.io/otel/metric" | ||
) | ||
|
||
func recordRuntimeMetrics(meter metric.Meter) error { | ||
// Create metric instruments | ||
|
||
var ( | ||
err error | ||
|
||
memSys metric.Int64ObservableUpDownCounter | ||
pauseTotalMs metric.Int64ObservableCounter | ||
) | ||
|
||
if pauseTotalMs, err = meter.Int64ObservableCounter( | ||
"process.runtime.go.gc.pause_total_ms", | ||
metric.WithDescription("Cumulative nanoseconds in GC stop-the-world pauses since the program started"), | ||
); err != nil { | ||
return err | ||
} | ||
|
||
if memSys, err = meter.Int64ObservableUpDownCounter( | ||
"process.runtime.go.mem.sys", | ||
metric.WithUnit("By"), | ||
metric.WithDescription("Bytes of memory obtained from the OS"), | ||
); err != nil { | ||
return err | ||
} | ||
|
||
// Record the runtime stats periodically | ||
if _, err := meter.RegisterCallback( | ||
func(ctx context.Context, o metric.Observer) error { | ||
var memStats runtime.MemStats | ||
runtime.ReadMemStats(&memStats) | ||
|
||
o.ObserveInt64(pauseTotalMs, clampUint64(memStats.PauseTotalNs)/1e6) // GC Pause in ms | ||
o.ObserveInt64(memSys, clampUint64(memStats.Sys)) | ||
return nil | ||
}, | ||
pauseTotalMs, memSys, | ||
); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func clampUint64(v uint64) int64 { | ||
if v > math.MaxInt64 { | ||
return math.MaxInt64 | ||
} | ||
return int64(v) | ||
} |
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
File renamed without changes.