Documentation ¶
Overview ¶
Package semconv implements OpenTelemetry semantic conventions.
This package is currently in a pre-GA phase. Backwards incompatible changes may be introduced in subsequent minor version releases as we work to track the evolving OpenTelemetry specification and user feedback.
OpenTelemetry semantic conventions are agreed standardized naming patterns for OpenTelemetry things. This package aims to be the centralized place to interact with these conventions.
Index ¶
- Constants
- Variables
- func EndUserAttributesFromHTTPRequest(request *http.Request) []label.KeyValue
- func HTTPAttributesFromHTTPStatusCode(code int) []label.KeyValue
- func HTTPClientAttributesFromHTTPRequest(request *http.Request) []label.KeyValue
- func HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []label.KeyValue
- func HTTPServerMetricAttributesFromHTTPRequest(serverName string, request *http.Request) []label.KeyValue
- func NetAttributesFromHTTPRequest(network string, request *http.Request) []label.KeyValue
- func SpanStatusFromHTTPStatusCode(code int) (codes.Code, string)
Constants ¶
const ( // Name of the service. ServiceNameKey = label.Key("service.name") // A namespace for `service.name`. This needs to have meaning that helps // to distinguish a group of services. For example, the team name that // owns a group of services. `service.name` is expected to be unique // within the same namespace. ServiceNamespaceKey = label.Key("service.namespace") // A unique identifier of the service instance. In conjunction with the // `service.name` and `service.namespace` this must be unique. ServiceInstanceIDKey = label.Key("service.instance.id") // The version of the service API. ServiceVersionKey = label.Key("service.version") )
Semantic conventions for service resource attribute keys.
const ( // The name of the telemetry SDK. // // The default OpenTelemetry SDK provided by the OpenTelemetry project // MUST set telemetry.sdk.name to the value `opentelemetry`. // // If another SDK is used, this attribute MUST be set to the import path // of that SDK's package. // // The value `opentelemetry` is reserved and MUST NOT be used by // non-OpenTelemetry SDKs. TelemetrySDKNameKey = label.Key("telemetry.sdk.name") // The language of the telemetry SDK. TelemetrySDKLanguageKey = label.Key("telemetry.sdk.language") // The version string of the telemetry SDK. TelemetrySDKVersionKey = label.Key("telemetry.sdk.version") )
Semantic conventions for telemetry SDK resource attribute keys.
const ( // A uniquely identifying name for the Container. ContainerNameKey = label.Key("container.name") // Container ID, usually a UUID, as for example used to // identify Docker containers. The UUID might be abbreviated. ContainerIDKey = label.Key("container.id") // Name of the image the container was built on. ContainerImageNameKey = label.Key("container.image.name") // Container image tag. ContainerImageTagKey = label.Key("container.image.tag") )
Semantic conventions for container resource attribute keys.
const ( // A uniquely identifying name for the FaaS. FaaSNameKey = label.Key("faas.name") // The unique name of the function being executed. FaaSIDKey = label.Key("faas.id") // The version of the function being executed. FaaSVersionKey = label.Key("faas.version") // The execution environment identifier. FaaSInstanceKey = label.Key("faas.instance") )
Semantic conventions for Function-as-a-Service resource attribute keys.
const ( // Process identifier (PID). ProcessPIDKey = label.Key("process.pid") // The name of the process executable. On Linux based systems, can be // set to the `Name` in `proc/[pid]/status`. On Windows, can be set to // the base name of `GetProcessImageFileNameW`. ProcessExecutableNameKey = label.Key("process.executable.name") // The full path to the process executable. On Linux based systems, can // be set to the target of `proc/[pid]/exe`. On Windows, can be set to // the result of `GetProcessImageFileNameW`. ProcessExecutablePathKey = label.Key("process.executable.path") // The command used to launch the process (i.e. the command name). On // Linux based systems, can be set to the zeroth string in // `proc/[pid]/cmdline`. On Windows, can be set to the first parameter // extracted from `GetCommandLineW`. ProcessCommandKey = label.Key("process.command") // The full command used to launch the process. The value can be either // a list of strings representing the ordered list of arguments, or a // single string representing the full command. On Linux based systems, // can be set to the list of null-delimited strings extracted from // `proc/[pid]/cmdline`. On Windows, can be set to the result of // `GetCommandLineW`. ProcessCommandLineKey = label.Key("process.command_line") // The username of the user that owns the process. ProcessOwnerKey = label.Key("process.owner") )
Semantic conventions for operating system process resource attribute keys.
const ( // A uniquely identifying name for the Kubernetes cluster. Kubernetes // does not have cluster names as an internal concept so this may be // set to any meaningful value within the environment. For example, // GKE clusters have a name which can be used for this label. K8SClusterNameKey = label.Key("k8s.cluster.name") // The name of the namespace that the pod is running in. K8SNamespaceNameKey = label.Key("k8s.namespace.name") // The uid of the Pod. K8SPodUIDKey = label.Key("k8s.pod.uid") // The name of the pod. K8SPodNameKey = label.Key("k8s.pod.name") // The name of the Container in a Pod template. K8SContainerNameKey = label.Key("k8s.container.name") // The uid of the ReplicaSet. K8SReplicaSetUIDKey = label.Key("k8s.replicaset.uid") // The name of the ReplicaSet. K8SReplicaSetNameKey = label.Key("k8s.replicaset.name") // The uid of the Deployment. K8SDeploymentUIDKey = label.Key("k8s.deployment.uid") // The name of the deployment. K8SDeploymentNameKey = label.Key("k8s.deployment.name") // The uid of the StatefulSet. K8SStatefulSetUIDKey = label.Key("k8s.statefulset.uid") // The name of the StatefulSet. K8SStatefulSetNameKey = label.Key("k8s.statefulset.name") // The uid of the DaemonSet. K8SDaemonSetUIDKey = label.Key("k8s.daemonset.uid") // The name of the DaemonSet. K8SDaemonSetNameKey = label.Key("k8s.daemonset.name") // The uid of the Job. K8SJobUIDKey = label.Key("k8s.job.uid") // The name of the Job. K8SJobNameKey = label.Key("k8s.job.name") // The uid of the CronJob. K8SCronJobUIDKey = label.Key("k8s.cronjob.uid") // The name of the CronJob. K8SCronJobNameKey = label.Key("k8s.cronjob.name") )
Semantic conventions for Kubernetes resource attribute keys.
const ( // A uniquely identifying name for the host: 'hostname', FQDN, or user specified name HostNameKey = label.Key("host.name") // Unique host ID. For cloud environments this will be the instance ID. HostIDKey = label.Key("host.id") // Type of host. For cloud environments this will be the machine type. HostTypeKey = label.Key("host.type") // Name of the OS or VM image the host is running. HostImageNameKey = label.Key("host.image.name") // Identifier of the image the host is running. HostImageIDKey = label.Key("host.image.id") // Version of the image the host is running. HostImageVersionKey = label.Key("host.image.version") )
Semantic conventions for host resource attribute keys.
const ( // Name of the cloud provider. CloudProviderKey = label.Key("cloud.provider") // The account ID from the cloud provider used for authorization. CloudAccountIDKey = label.Key("cloud.account.id") // Geographical region where this resource is. CloudRegionKey = label.Key("cloud.region") // Zone of the region where this resource is. CloudZoneKey = label.Key("cloud.zone") )
Semantic conventions for cloud environment resource attribute keys.
const ( // Transport protocol used. NetTransportKey = label.Key("net.transport") // Remote address of the peer. NetPeerIPKey = label.Key("net.peer.ip") // Remote port number. NetPeerPortKey = label.Key("net.peer.port") // Remote hostname or similar. NetPeerNameKey = label.Key("net.peer.name") // Local host IP. Useful in case of a multi-IP host. NetHostIPKey = label.Key("net.host.ip") // Local host port. NetHostPortKey = label.Key("net.host.port") // Local hostname or similar. NetHostNameKey = label.Key("net.host.name") )
Semantic conventions for attribute keys used for network related operations.
const ( // Username or the client identifier extracted from the access token or // authorization header in the inbound request from outside the system. EnduserIDKey = label.Key("enduser.id") // Actual or assumed role the client is making the request with. EnduserRoleKey = label.Key("enduser.role") // Scopes or granted authorities the client currently possesses. EnduserScopeKey = label.Key("enduser.scope") )
Semantic conventions for attribute keys used to identify an authorized user.
const ( // HTTP request method. HTTPMethodKey = label.Key("http.method") // Full HTTP request URL in the form: // scheme://host[:port]/path?query[#fragment]. HTTPURLKey = label.Key("http.url") // The full request target as passed in a HTTP request line or // equivalent, e.g. "/path/12314/?q=ddds#123". HTTPTargetKey = label.Key("http.target") // The value of the HTTP host header. HTTPHostKey = label.Key("http.host") // The URI scheme identifying the used protocol. HTTPSchemeKey = label.Key("http.scheme") // HTTP response status code. HTTPStatusCodeKey = label.Key("http.status_code") // Kind of HTTP protocol used. HTTPFlavorKey = label.Key("http.flavor") // Value of the HTTP User-Agent header sent by the client. HTTPUserAgentKey = label.Key("http.user_agent") // The primary server name of the matched virtual host. HTTPServerNameKey = label.Key("http.server_name") // The matched route served (path template). For example, // "/users/:userID?". HTTPRouteKey = label.Key("http.route") // The IP address of the original client behind all proxies, if known // (e.g. from X-Forwarded-For). HTTPClientIPKey = label.Key("http.client_ip") // The size of the request payload body in bytes. HTTPRequestContentLengthKey = label.Key("http.request_content_length") // The size of the uncompressed request payload body after transport decoding. // Not set if transport encoding not used. HTTPRequestContentLengthUncompressedKey = label.Key("http.request_content_length_uncompressed") // The size of the response payload body in bytes. HTTPResponseContentLengthKey = label.Key("http.response_content_length") // The size of the uncompressed response payload body after transport decoding. // Not set if transport encoding not used. HTTPResponseContentLengthUncompressedKey = label.Key("http.response_content_length_uncompressed") )
Semantic conventions for attribute keys for HTTP.
const ( // Identifier for the database system (DBMS) being used. DBSystemKey = label.Key("db.system") // Database Connection String with embedded credentials removed. DBConnectionStringKey = label.Key("db.connection_string") // Username for accessing database. DBUserKey = label.Key("db.user") )
Semantic conventions for attribute keys for database connections.
const ( // Database instance name. DBNameKey = label.Key("db.name") // A database statement for the given database type. DBStatementKey = label.Key("db.statement") // A database operation for the given database type. DBOperationKey = label.Key("db.operation") )
Semantic conventions for attribute keys for database calls.
const ( // Name of the Cassandra keyspace accessed. Use instead of `db.name`. DBCassandraKeyspaceKey = label.Key("db.cassandra.keyspace") // HBase namespace accessed. Use instead of `db.name`. DBHBaseNamespaceKey = label.Key("db.hbase.namespace") // Index of Redis database accessed. Use instead of `db.name`. DBRedisDBIndexKey = label.Key("db.redis.database_index") // Collection being accessed within the database in `db.name`. DBMongoDBCollectionKey = label.Key("db.mongodb.collection") )
Database technology-specific attributes
const ( // A string identifying the remoting system. RPCSystemKey = label.Key("rpc.system") // The full name of the service being called. RPCServiceKey = label.Key("rpc.service") // The name of the method being called. RPCMethodKey = label.Key("rpc.method") // Name of message transmitted or received. RPCNameKey = label.Key("name") // Type of message transmitted or received. RPCMessageTypeKey = label.Key("message.type") // Identifier of message transmitted or received. RPCMessageIDKey = label.Key("message.id") // The compressed size of the message transmitted or received in bytes. RPCMessageCompressedSizeKey = label.Key("message.compressed_size") // The uncompressed size of the message transmitted or received in // bytes. RPCMessageUncompressedSizeKey = label.Key("message.uncompressed_size") )
Semantic conventions for attribute keys for RPC.
const ( // A unique identifier describing the messaging system. For example, // kafka, rabbitmq or activemq. MessagingSystemKey = label.Key("messaging.system") // The message destination name, e.g. MyQueue or MyTopic. MessagingDestinationKey = label.Key("messaging.destination") // The kind of message destination. MessagingDestinationKindKey = label.Key("messaging.destination_kind") // Describes if the destination is temporary or not. MessagingTempDestinationKey = label.Key("messaging.temp_destination") // The name of the transport protocol. MessagingProtocolKey = label.Key("messaging.protocol") // The version of the transport protocol. MessagingProtocolVersionKey = label.Key("messaging.protocol_version") // Messaging service URL. MessagingURLKey = label.Key("messaging.url") // Identifier used by the messaging system for a message. MessagingMessageIDKey = label.Key("messaging.message_id") // Identifier used by the messaging system for a conversation. MessagingConversationIDKey = label.Key("messaging.conversation_id") // The (uncompressed) size of the message payload in bytes. MessagingMessagePayloadSizeBytesKey = label.Key("messaging.message_payload_size_bytes") // The compressed size of the message payload in bytes. MessagingMessagePayloadCompressedSizeBytesKey = label.Key("messaging.message_payload_compressed_size_bytes") // Identifies which part and kind of message consumption is being // preformed. MessagingOperationKey = label.Key("messaging.operation") // RabbitMQ specific attribute describing the destination routing key. MessagingRabbitMQRoutingKeyKey = label.Key("messaging.rabbitmq.routing_key") )
Semantic conventions for attribute keys for messaging systems.
const ( // Type of the trigger on which the function is executed. FaaSTriggerKey = label.Key("faas.trigger") // String containing the execution identifier of the function. FaaSExecutionKey = label.Key("faas.execution") // A boolean indicating that the serverless function is executed // for the first time (aka cold start). FaaSColdstartKey = label.Key("faas.coldstart") // The name of the source on which the operation was performed. // For example, in Cloud Storage or S3 corresponds to the bucket name, // and in Cosmos DB to the database name. FaaSDocumentCollectionKey = label.Key("faas.document.collection") // The type of the operation that was performed on the data. FaaSDocumentOperationKey = label.Key("faas.document.operation") // A string containing the time when the data was accessed. FaaSDocumentTimeKey = label.Key("faas.document.time") // The document name/table subjected to the operation. FaaSDocumentNameKey = label.Key("faas.document.name") // The function invocation time. FaaSTimeKey = label.Key("faas.time") // The schedule period as Cron Expression. FaaSCronKey = label.Key("faas.cron") )
Semantic conventions for attribute keys for FaaS systems.
const ( // Name of the deployment environment (aka deployment tier); e.g. (staging, production). DeploymentEnvironmentKey = label.Key("deployment.environment") )
Semantic conventions for deployment attributes.
const ( // Service name of the remote service. Should equal the actual // `service.name` resource attribute of the remote service, if any. PeerServiceKey = label.Key("peer.service") )
General attribute keys for spans.
Variables ¶
var ( CloudProviderAWS = CloudProviderKey.String("aws") CloudProviderAzure = CloudProviderKey.String("azure") CloudProviderGCP = CloudProviderKey.String("gcp") )
Semantic conventions for common cloud provider resource attributes.
var ( NetTransportTCP = NetTransportKey.String("IP.TCP") NetTransportUDP = NetTransportKey.String("IP.UDP") NetTransportIP = NetTransportKey.String("IP") NetTransportUnix = NetTransportKey.String("Unix") NetTransportPipe = NetTransportKey.String("pipe") NetTransportInProc = NetTransportKey.String("inproc") NetTransportOther = NetTransportKey.String("other") )
Semantic conventions for common transport protocol attributes.
var ( // Semantic conventions for HTTP(S) URI schemes. HTTPSchemeHTTP = HTTPSchemeKey.String("http") HTTPSchemeHTTPS = HTTPSchemeKey.String("https") // Semantic conventions for HTTP protocols. HTTPFlavor1_0 = HTTPFlavorKey.String("1.0") HTTPFlavor1_1 = HTTPFlavorKey.String("1.1") HTTPFlavor2 = HTTPFlavorKey.String("2") HTTPFlavorSPDY = HTTPFlavorKey.String("SPDY") HTTPFlavorQUIC = HTTPFlavorKey.String("QUIC") )
Semantic conventions for common HTTP attributes.
var ( DBSystemDB2 = DBSystemKey.String("db2") // IBM DB2 DBSystemDerby = DBSystemKey.String("derby") // Apache Derby DBSystemHive = DBSystemKey.String("hive") // Apache Hive DBSystemMariaDB = DBSystemKey.String("mariadb") // MariaDB DBSystemMSSql = DBSystemKey.String("mssql") // Microsoft SQL Server DBSystemMySQL = DBSystemKey.String("mysql") // MySQL DBSystemOracle = DBSystemKey.String("oracle") // Oracle Database DBSystemPostgres = DBSystemKey.String("postgresql") // PostgreSQL DBSystemSqlite = DBSystemKey.String("sqlite") // SQLite DBSystemTeradata = DBSystemKey.String("teradata") // Teradata DBSystemOtherSQL = DBSystemKey.String("other_sql") // Some other Sql database. Fallback only DBSystemCassandra = DBSystemKey.String("cassandra") // Cassandra DBSystemCosmosDB = DBSystemKey.String("cosmosdb") // Microsoft Azure CosmosDB DBSystemCouchbase = DBSystemKey.String("couchbase") // Couchbase DBSystemCouchDB = DBSystemKey.String("couchdb") // CouchDB DBSystemDynamoDB = DBSystemKey.String("dynamodb") // Amazon DynamoDB DBSystemHBase = DBSystemKey.String("hbase") // HBase DBSystemMongodb = DBSystemKey.String("mongodb") // MongoDB DBSystemNeo4j = DBSystemKey.String("neo4j") // Neo4j DBSystemRedis = DBSystemKey.String("redis") // Redis )
Semantic conventions for common database system attributes.
var ( // Semantic convention for gRPC as the remoting system. RPCSystemGRPC = RPCSystemKey.String("grpc") // Semantic convention for a message named message. RPCNameMessage = RPCNameKey.String("message") // Semantic conventions for RPC message types. RPCMessageTypeSent = RPCMessageTypeKey.String("SENT") RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED") )
Semantic conventions for common RPC attributes.
var ( // Semantic conventions for message destinations. MessagingDestinationKindKeyQueue = MessagingDestinationKindKey.String("queue") MessagingDestinationKindKeyTopic = MessagingDestinationKindKey.String("topic") // Semantic convention for message destinations that are temporary. MessagingTempDestination = MessagingTempDestinationKey.Bool(true) // Semantic convention for the operation parts of message consumption. // This does not include a "send" attribute as that is explicitly not // allowed in the OpenTelemetry specification. MessagingOperationReceive = MessagingOperationKey.String("receive") MessagingOperationProcess = MessagingOperationKey.String("process") )
Semantic conventions for common messaging system attributes.
var ( // Semantic conventions for the types of triggers. FaasTriggerDatasource = FaaSTriggerKey.String("datasource") FaasTriggerHTTP = FaaSTriggerKey.String("http") FaasTriggerPubSub = FaaSTriggerKey.String("pubsub") FaasTriggerTimer = FaaSTriggerKey.String("timer") FaasTriggerOther = FaaSTriggerKey.String("other") // Semantic conventions for the types of operations performed. FaaSDocumentOperationInsert = FaaSDocumentOperationKey.String("insert") FaaSDocumentOperationEdit = FaaSDocumentOperationKey.String("edit") FaaSDocumentOperationDelete = FaaSDocumentOperationKey.String("delete") )
Semantic conventions for common FaaS system attributes.
var (
TelemetrySDKLanguageGo = TelemetrySDKLanguageKey.String("go")
)
Semantic conventions for telemetry SDK resource attributes.
Functions ¶
func EndUserAttributesFromHTTPRequest ¶
EndUserAttributesFromHTTPRequest generates attributes of the enduser namespace as specified by the OpenTelemetry specification for a span.
func HTTPAttributesFromHTTPStatusCode ¶
HTTPAttributesFromHTTPStatusCode generates attributes of the http namespace as specified by the OpenTelemetry specification for a span.
func HTTPClientAttributesFromHTTPRequest ¶
HTTPClientAttributesFromHTTPRequest generates attributes of the http namespace as specified by the OpenTelemetry specification for a span on the client side.
func HTTPServerAttributesFromHTTPRequest ¶
func HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []label.KeyValue
HTTPServerAttributesFromHTTPRequest generates attributes of the http namespace as specified by the OpenTelemetry specification for a span on the server side. Currently, only basic authentication is supported.
func HTTPServerMetricAttributesFromHTTPRequest ¶
func HTTPServerMetricAttributesFromHTTPRequest(serverName string, request *http.Request) []label.KeyValue
HTTPServerMetricAttributesFromHTTPRequest generates low-cardinality attributes to be used with server-side HTTP metrics.
func NetAttributesFromHTTPRequest ¶
NetAttributesFromHTTPRequest generates attributes of the net namespace as specified by the OpenTelemetry specification for a span. The network parameter is a string that net.Dial function from standard library can understand.
Types ¶
This section is empty.