Skip to content

Latest commit

 

History

History
55 lines (46 loc) · 1.2 KB

File metadata and controls

55 lines (46 loc) · 1.2 KB

semconv

Standard and custom semantic conventions for creating consistent, comparable attribute.Keys across services.

usage

Import semconv and use it exclusively for defining attribute keys in telemetry.

import (
	"github.com/getlantern/semconv"
	"go.opentelemetry.io/otel/attribute"
)

Example attribute map:

attrs := map[attribute.Key]attribute.Value{
	semconv.GeoCountryISOCodeKey: attribute.StringValue("US"),
	semconv.HostNameKey:          attribute.StringValue("phost-abcd"),
	semconv.TrackNameKey:         attribute.StringValue("nidoran"),
	semconv.ProxyProtocolKey:     attribute.StringValue("HTTPS"),
}

Example attribute slice:

attrs := []attribute.KeyValue{
	{
		Key:   semconv.GeoCountryISOCodeKey,
		Value: attribute.StringValue("US"),
	},
	{
		Key:   semconv.HostNameKey,
		Value: attribute.StringValue("phost-abcd"),
	},
	{
		Key:   semconv.TrackNameKey,
		Value: attribute.StringValue("nidoran"),
	},
	{
		Key:   semconv.ProxyProtocolKey,
		Value: attribute.StringValue("HTTPS"),
	},
}

reference

standard

custom