mirror of
https://github.com/hanzoai/traces.git
synced 2026-11-03 04:05:45 +00:00
* Update Prometheus to v0.307.2 * Update otel collector * Update OTel collector
29 lines
955 B
Go
29 lines
955 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package otelconftelemetry // import "go.opentelemetry.io/collector/service/telemetry/otelconftelemetry"
|
|
|
|
import (
|
|
"context"
|
|
|
|
config "go.opentelemetry.io/contrib/otelconf/v0.3.0"
|
|
sdkresource "go.opentelemetry.io/otel/sdk/resource"
|
|
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
|
)
|
|
|
|
func newSDK(ctx context.Context, res *sdkresource.Resource, conf config.OpenTelemetryConfiguration) (config.SDK, error) {
|
|
resourceAttrs := make([]config.AttributeNameValue, 0, res.Len())
|
|
for _, r := range res.Attributes() {
|
|
key := string(r.Key)
|
|
resourceAttrs = append(resourceAttrs, config.AttributeNameValue{
|
|
Name: key,
|
|
Value: mustAttributeValueString(key, r.Value),
|
|
})
|
|
}
|
|
conf.Resource = &config.Resource{
|
|
SchemaUrl: ptr(semconv.SchemaURL),
|
|
Attributes: resourceAttrs,
|
|
}
|
|
return config.NewSDK(config.WithContext(ctx), config.WithOpenTelemetryConfiguration(conf))
|
|
}
|