You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-19 21:45:50 +02:00
Upgrade semconv use to v1.39.0 (#7854)
Resolve #7806 - Replace use of `rpc.grpc.status_code` with `rpc.response.status_code` (https://github.com/open-telemetry/semantic-conventions/issues/1504) - Pin zipkin semconv to use 1.38.0 for deprecated `PeerServiceKey` (https://github.com/open-telemetry/opentelemetry-specification/blob/343c2abbcb86a94292bd7cd55e96edcea5a96113/specification/trace/sdk_exporters/zipkin.md#otlp---zipkin) --------- Co-authored-by: Robert Pająk <pellared@hotmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -27,6 +27,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- Improve performance of concurrent synchronous gauge measurements in `go.opentelemetry.io/otel/sdk/metric`. (#7478)
|
||||
- Improve performance of concurrent exponential histogram measurements in `go.opentelemetry.io/otel/sdk/metric`. (#7702)
|
||||
- Improve the concurrent performance of `FixedSizeReservoir` in `go.opentelemetry.io/otel/sdk/metric/exemplar`. (#7447)
|
||||
- The `rpc.grpc.status_code` attribute in the experimental metrics emitted from `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` is replaced with the `rpc.response.status_code` attribute to align with the semantic conventions. (#7854)
|
||||
- The `rpc.grpc.status_code` attribute in the experimental metrics emitted from `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` is replaced with the `rpc.response.status_code` attribute to align with the semantic conventions. (#7854)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ import (
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.37.0/otelconv"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.39.0/otelconv"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -693,10 +693,8 @@ func TestClientObservability(t *testing.T) {
|
||||
otelconv.SDKExporterOperationDuration{}.AttrComponentType(
|
||||
otelconv.ComponentTypeOtlpGRPCLogExporter,
|
||||
),
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCGRPCStatusCode(
|
||||
otelconv.RPCGRPCStatusCodeAttr(
|
||||
codes.OK,
|
||||
),
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCResponseStatusCode(
|
||||
codes.OK.String(),
|
||||
),
|
||||
serverAddrAttrs[0],
|
||||
serverAddrAttrs[1],
|
||||
@@ -833,10 +831,8 @@ func TestClientObservability(t *testing.T) {
|
||||
otelconv.SDKExporterOperationDuration{}.AttrComponentType(
|
||||
otelconv.ComponentTypeOtlpGRPCLogExporter,
|
||||
),
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCGRPCStatusCode(
|
||||
otelconv.RPCGRPCStatusCodeAttr(
|
||||
status.Code(wantErr),
|
||||
),
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCResponseStatusCode(
|
||||
status.Code(wantErr).String(),
|
||||
),
|
||||
serverAddrAttrs[0],
|
||||
serverAddrAttrs[1],
|
||||
@@ -880,7 +876,7 @@ func TestClientObservability(t *testing.T) {
|
||||
wantErr = errors.Join(wantErr, err)
|
||||
|
||||
wantErrTypeAttr := semconv.ErrorType(wantErr)
|
||||
wantGRPCStatusCodeAttr := otelconv.RPCGRPCStatusCodeAttr(codes.InvalidArgument)
|
||||
wantGRPCStatus := codes.InvalidArgument
|
||||
rCh := make(chan exportResult, 1)
|
||||
rCh <- exportResult{
|
||||
Err: err,
|
||||
@@ -968,8 +964,8 @@ func TestClientObservability(t *testing.T) {
|
||||
otelconv.SDKExporterOperationDuration{}.AttrComponentType(
|
||||
otelconv.ComponentTypeOtlpGRPCLogExporter,
|
||||
),
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCGRPCStatusCode(
|
||||
wantGRPCStatusCodeAttr,
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCResponseStatusCode(
|
||||
wantGRPCStatus.String(),
|
||||
),
|
||||
serverAddrAttrs[0],
|
||||
serverAddrAttrs[1],
|
||||
@@ -1148,10 +1144,8 @@ func TestClientObservabilityWithRetry(t *testing.T) {
|
||||
otelconv.SDKExporterOperationDuration{}.AttrComponentType(
|
||||
otelconv.ComponentTypeOtlpGRPCLogExporter,
|
||||
),
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCGRPCStatusCode(
|
||||
otelconv.RPCGRPCStatusCodeAttr(
|
||||
status.Code(wantErr),
|
||||
),
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCResponseStatusCode(
|
||||
status.Code(wantErr).String(),
|
||||
),
|
||||
serverAddrAttrs[0],
|
||||
serverAddrAttrs[1],
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
@@ -20,8 +21,8 @@ import (
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal/x"
|
||||
"go.opentelemetry.io/otel/internal/global"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.37.0/otelconv"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.39.0/otelconv"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -149,7 +150,7 @@ func NewInstrumentation(id int64, target string) (*Instrumentation, error) {
|
||||
i.addOpt = metric.WithAttributeSet(attribute.NewSet(i.presetAttrs...))
|
||||
i.recOpt = metric.WithAttributeSet(attribute.NewSet(append(
|
||||
// Default to OK status code.
|
||||
[]attribute.KeyValue{semconv.RPCGRPCStatusCodeOk},
|
||||
[]attribute.KeyValue{semconv.RPCResponseStatusCode(codes.OK.String())},
|
||||
i.presetAttrs...,
|
||||
)...))
|
||||
return i, nil
|
||||
@@ -230,10 +231,10 @@ func (i *Instrumentation) recordOption(err error) metric.RecordOption {
|
||||
defer put(attrsPool, attrs)
|
||||
|
||||
*attrs = append(*attrs, i.presetAttrs...)
|
||||
code := int64(status.Code(err))
|
||||
code := status.Code(err)
|
||||
*attrs = append(
|
||||
*attrs,
|
||||
semconv.RPCGRPCStatusCodeKey.Int64(code),
|
||||
semconv.RPCResponseStatusCode(code.String()),
|
||||
semconv.ErrorType(err),
|
||||
)
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ import (
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.37.0/otelconv"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.39.0/otelconv"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -175,7 +175,7 @@ func logOperationDurationMetrics(err error, code codes.Code) metricdata.Metrics
|
||||
attrs := []attribute.KeyValue{
|
||||
semconv.OTelComponentName(GetComponentName(ID)),
|
||||
semconv.OTelComponentTypeKey.String(string(otelconv.ComponentTypeOtlpGRPCLogExporter)),
|
||||
semconv.RPCGRPCStatusCodeKey.Int64(int64(code)),
|
||||
semconv.RPCResponseStatusCode(code.String()),
|
||||
}
|
||||
attrs = append(attrs, ServerAddrAttrs(TARGET)...)
|
||||
if err != nil {
|
||||
|
||||
@@ -39,7 +39,7 @@ import (
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
"go.opentelemetry.io/otel/sdk/trace/tracetest"
|
||||
"go.opentelemetry.io/otel/semconv/v1.37.0/otelconv"
|
||||
"go.opentelemetry.io/otel/semconv/v1.39.0/otelconv"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -519,8 +519,8 @@ func TestClientInstrumentation(t *testing.T) {
|
||||
{Attributes: attribute.NewSet(append(
|
||||
attrs,
|
||||
otelconv.SDKExporterOperationDuration{}.AttrErrorType("*errors.joinError"),
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCGRPCStatusCode(
|
||||
otelconv.RPCGRPCStatusCodeOk,
|
||||
otelconv.SDKExporterOperationDuration{}.AttrRPCResponseStatusCode(
|
||||
codes.OK.String(),
|
||||
),
|
||||
)...)},
|
||||
},
|
||||
|
||||
@@ -18,8 +18,8 @@ import (
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x"
|
||||
"go.opentelemetry.io/otel/internal/global"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.37.0/otelconv"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.39.0/otelconv"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -116,7 +116,9 @@ func NewInstrumentation(id int64, target string) (*Instrumentation, error) {
|
||||
// Do not modify attrs (NewSet sorts in-place), make a new slice.
|
||||
recOpt: metric.WithAttributeSet(attribute.NewSet(append(
|
||||
// Default to OK status code.
|
||||
[]attribute.KeyValue{semconv.RPCGRPCStatusCodeOk},
|
||||
[]attribute.KeyValue{
|
||||
semconv.RPCResponseStatusCode(codes.OK.String()),
|
||||
},
|
||||
attrs...,
|
||||
)...)),
|
||||
}
|
||||
@@ -291,8 +293,7 @@ func (i *Instrumentation) recordOption(err error, code codes.Code) metric.Record
|
||||
defer put(measureAttrsPool, attrs)
|
||||
*attrs = append(*attrs, i.attrs...)
|
||||
|
||||
c := int64(code) // uint32 -> int64.
|
||||
*attrs = append(*attrs, semconv.RPCGRPCStatusCodeKey.Int64(c))
|
||||
*attrs = append(*attrs, semconv.RPCResponseStatusCode(code.String()))
|
||||
if err != nil {
|
||||
*attrs = append(*attrs, semconv.ErrorType(err))
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.37.0/otelconv"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.39.0/otelconv"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -171,10 +171,10 @@ func spanExported(success, total int64, err error) metricdata.Metrics {
|
||||
|
||||
func operationDuration(err error) metricdata.Metrics {
|
||||
rpcSet := func(err error) attribute.Set {
|
||||
c := int64(status.Code(err))
|
||||
c := status.Code(err)
|
||||
return attribute.NewSet(append(
|
||||
[]attribute.KeyValue{
|
||||
semconv.RPCGRPCStatusCodeKey.Int64(c),
|
||||
semconv.RPCResponseStatusCode(c.String()),
|
||||
},
|
||||
baseAttrs(err)...,
|
||||
)...)
|
||||
|
||||
@@ -20,7 +20,8 @@ import (
|
||||
semconv120 "go.opentelemetry.io/otel/semconv/v1.20.0"
|
||||
semconv121 "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
semconv125 "go.opentelemetry.io/otel/semconv/v1.25.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
semconv138 "go.opentelemetry.io/otel/semconv/v1.38.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
@@ -227,7 +228,7 @@ func toZipkinTags(data tracesdk.ReadOnlySpan) map[string]string {
|
||||
// Rank determines selection order for remote endpoint. See the specification
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.28.0/specification/trace/sdk_exporters/zipkin.md#otlp---zipkin
|
||||
var remoteEndpointKeyRank = map[attribute.Key]int{
|
||||
semconv.PeerServiceKey: 1,
|
||||
semconv138.PeerServiceKey: 1,
|
||||
semconv.ServerAddressKey: 2,
|
||||
semconv120.NetPeerNameKey: 3,
|
||||
semconv.NetworkPeerAddressKey: 4,
|
||||
|
||||
@@ -22,7 +22,8 @@ import (
|
||||
tracesdk "go.opentelemetry.io/otel/sdk/trace"
|
||||
"go.opentelemetry.io/otel/sdk/trace/tracetest"
|
||||
semconv125 "go.opentelemetry.io/otel/semconv/v1.25.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
semconv138 "go.opentelemetry.io/otel/semconv/v1.38.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
@@ -1154,7 +1155,7 @@ func TestRemoteEndpointTransformation(t *testing.T) {
|
||||
data: tracetest.SpanStub{
|
||||
SpanKind: trace.SpanKindProducer,
|
||||
Attributes: []attribute.KeyValue{
|
||||
semconv.PeerService("peer-service-test"),
|
||||
semconv138.PeerService("peer-service-test"),
|
||||
semconv.ServerAddress("server-address-test"),
|
||||
semconv.NetworkPeerAddress("10.1.2.80"),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user