diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8e7dc5d103e..ee3196450d6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -216,3 +216,13 @@ updates: schedule: day: sunday interval: weekly + - + package-ecosystem: gomod + directory: /internal/tools/semconv-gen + labels: + - dependencies + - go + - "Skip Changelog" + schedule: + day: sunday + interval: weekly diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b0c028bec7..b2cda4b4fd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `ExportSpans` method of the`SpanExporter` interface type was updated to accept `ReadOnlySpan`s instead of the removed `SpanSnapshot`. This brings the export interface into compliance with the specification in that it now accepts an explicitly immutable type instead of just an implied one. (#1873) - Unembed `SpanContext` in `Link`. (#1877) +- Semantic conventions are now generated from the specification YAML. (#1891) - Spans created by the global `Tracer` obtained from `go.opentelemetry.io/otel`, prior to a functioning `TracerProvider` being set, now propagate the span context from their parent if one exists. (#1901) - Move the `go.opentelemetry.io/otel/unit` package to `go.opentelemetry.io/otel/metric/unit`. (#1903) diff --git a/Makefile b/Makefile index b290b667101..49bd0e00f4c 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,9 @@ $(TOOLS)/%: | $(TOOLS) cd $(TOOLS_MOD_DIR) && \ $(GO) build -o $@ $(PACKAGE) +SEMCONVGEN = $(TOOLS)/semconv-gen +$(TOOLS)/semconv-gen: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/semconv-gen + CROSSLINK = $(TOOLS)/crosslink $(TOOLS)/crosslink: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/crosslink @@ -55,7 +58,7 @@ $(TOOLS)/stringer: PACKAGE=golang.org/x/tools/cmd/stringer $(TOOLS)/gojq: PACKAGE=github.com/itchyny/gojq/cmd/gojq .PHONY: tools -tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(STRINGER) $(TOOLS)/gojq +tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(STRINGER) $(TOOLS)/gojq $(SEMCONVGEN) # Build diff --git a/RELEASING.md b/RELEASING.md index b6cbd1231b7..29f8ce7d700 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,5 +1,24 @@ # Release Process +## Semantic Convention Generation + +If a new version of the OpenTelemetry Specification has been released it will be necessary to generate a new +semantic convention package from the YAML definitions in the specification repository. There is a utility in +`internal/tools/semconv-gen` that can be used to generate the `semconv` package. This will ideally be done +shortly after the specification release is tagged, but it is also good practice to ensure that current conventions +are current before creating a release tag. + +There are currently two categories of semantic conventions that must be generated, `resource` and `trace`. + +``` +cd internal/tools/semconv-gen +go run generate.go -i /path/to/specification/repo/semantic_conventions/resource +go run generate.go -i /path/to/specification/repo/semantic_conventions/trace +``` + +Using default values for all options other than `input` will result in using the `template.j2` template to +generate `resource.go` and `trace.go` in `/path/to/otelgo/repo/semconv`. + ## Pre-Release Update go.mod for submodules to depend on the new release which will happen in the next step. diff --git a/internal/tools/go.mod b/internal/tools/go.mod index 05024bea55c..0c76cf5533d 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -7,6 +7,7 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/golangci/golangci-lint v1.39.0 github.com/itchyny/gojq v0.12.3 + github.com/spf13/pflag v1.0.5 golang.org/x/tools v0.1.0 ) diff --git a/internal/tools/semconv-gen/generator.go b/internal/tools/semconv-gen/generator.go new file mode 100644 index 00000000000..7c44aaf3783 --- /dev/null +++ b/internal/tools/semconv-gen/generator.go @@ -0,0 +1,319 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "bytes" + "errors" + "fmt" + "io/ioutil" + "os" + "os/exec" + "path" + "path/filepath" + "regexp" + "strings" + + flag "github.com/spf13/pflag" +) + +func main() { + cfg := config{} + flag.StringVarP(&cfg.inputPath, "input", "i", "", "Path to semantic convention definition YAML") + flag.StringVarP(&cfg.outputPath, "output", "o", "semconv", "Path to output target. Must be either an absolute path or relative to the repository root.") + flag.StringVarP(&cfg.containerImage, "container", "c", "otel/semconvgen", "Container image ID") + flag.StringVarP(&cfg.outputFilename, "filename", "f", "", "Filename for templated output. If not specified 'basename(inputPath).go' will be used.") + flag.StringVarP(&cfg.templateFilename, "template", "t", "template.j2", "Template filename") + flag.Parse() + + cfg, err := validateConfig(cfg) + if err != nil { + fmt.Println(err) + flag.Usage() + os.Exit(-1) + } + + err = render(cfg) + if err != nil { + panic(err) + } + + err = fixIdentifiers(cfg.outputFilename) + if err != nil { + panic(err) + } + + err = format(cfg.outputFilename) + if err != nil { + panic(err) + } +} + +type config struct { + inputPath string + outputPath string + outputFilename string + templateFilename string + containerImage string +} + +func validateConfig(cfg config) (config, error) { + if cfg.inputPath == "" { + return config{}, errors.New("input path must be provided") + } + + if cfg.outputFilename == "" { + cfg.outputFilename = fmt.Sprintf("%s.go", path.Base(cfg.inputPath)) + } + + if !path.IsAbs(cfg.outputPath) { + root, err := findRepoRoot() + if err != nil { + return config{}, err + } + cfg.outputPath = path.Join(root, cfg.outputPath) + } + + cfg.outputFilename = path.Join(cfg.outputPath, cfg.outputFilename) + + if !path.IsAbs(cfg.templateFilename) { + pwd, err := os.Getwd() + if err != nil { + return config{}, err + } + cfg.templateFilename = path.Join(pwd, cfg.templateFilename) + } + + return cfg, nil +} + +func render(cfg config) error { + tmpDir, err := os.MkdirTemp("", "otel_semconvgen") + if err != nil { + return fmt.Errorf("unable to create temporary directory: %w", err) + } + defer os.RemoveAll(tmpDir) + + inputPath := path.Join(tmpDir, "input") + err = os.Mkdir(inputPath, 0700) + if err != nil { + return fmt.Errorf("unable to create input directory: %w", err) + } + + outputPath := path.Join(tmpDir, "output") + err = os.Mkdir(outputPath, 0700) + if err != nil { + return fmt.Errorf("unable to create output directory: %w", err) + } + + err = exec.Command("cp", "-a", cfg.inputPath, inputPath).Run() + if err != nil { + return fmt.Errorf("unable to copy input to temp directory: %w", err) + } + + err = exec.Command("cp", cfg.templateFilename, tmpDir).Run() + if err != nil { + return fmt.Errorf("unable to copy template to temp directory: %w", err) + } + + cmd := exec.Command("docker", "run", "--rm", + "-v", fmt.Sprintf("%s:/data", tmpDir), + cfg.containerImage, + "--yaml-root", path.Join("/data/input", path.Base(cfg.inputPath)), + "code", + "--template", path.Join("/data", path.Base(cfg.templateFilename)), + "--output", path.Join("/data/output", path.Base(cfg.outputFilename)), + ) + err = cmd.Run() + if err != nil { + return fmt.Errorf("unable to render template: %w", err) + } + + err = exec.Command("cp", path.Join(tmpDir, "output", path.Base(cfg.outputFilename)), cfg.outputPath).Run() + if err != nil { + return fmt.Errorf("unable to copy result to target: %w", err) + } + + return nil +} + +func findRepoRoot() (string, error) { + start, err := os.Getwd() + if err != nil { + return "", err + } + + dir := start + for { + _, err := os.Stat(filepath.Join(dir, ".git")) + if errors.Is(err, os.ErrNotExist) { + dir = filepath.Dir(dir) + // From https://golang.org/pkg/path/filepath/#Dir: + // The returned path does not end in a separator unless it is the root directory. + if strings.HasSuffix(dir, string(filepath.Separator)) { + return "", fmt.Errorf("unable to find git repository enclosing working dir %s", start) + } + continue + } + + if err != nil { + return "", err + } + + return dir, nil + } +} + +var capitalizations = []string{ + "ACL", + "AIX", + "AKS", + "AMD64", + "API", + "ARM32", + "ARM64", + "ARN", + "ARNs", + "ASCII", + "AWS", + "CPU", + "CSS", + "DB", + "DC", + "DNS", + "EC2", + "ECS", + "EDB", + "EKS", + "EOF", + "GCP", + "GRPC", + "GUID", + "HPUX", + "HSQLDB", + "HTML", + "HTTP", + "HTTPS", + "IA64", + "ID", + "IP", + "JDBC", + "JSON", + "K8S", + "LHS", + "MSSQL", + "OS", + "PHP", + "PID", + "PPC32", + "PPC64", + "QPS", + "QUIC", + "RAM", + "RHS", + "RPC", + "SDK", + "SLA", + "SMTP", + "SPDY", + "SQL", + "SSH", + "TCP", + "TLS", + "TTL", + "UDP", + "UID", + "UI", + "UUID", + "URI", + "URL", + "UTF8", + "VM", + "XML", + "XMPP", + "XSRF", + "XSS", + "ZOS", + "CronJob", + "WebEngine", + "MySQL", + "PostgreSQL", + "MariaDB", + "MaxDB", + "FirstSQL", + "InstantDB", + "HBase", + "MongoDB", + "CouchDB", + "CosmosDB", + "DynamoDB", + "HanaDB", + "FreeBSD", + "NetBSD", + "OpenBSD", + "DragonflyBSD", + "InProc", + "FaaS", +} + +// These are not simple capitalization fixes, but require string replacement. +// All occurrences of the key will be replaced with the corresponding value. +var replacements = map[string]string{ + "RedisDatabase": "RedisDB", + "IPTCP": "TCP", + "IPUDP": "UDP", + "Lineno": "LineNumber", +} + +func fixIdentifiers(fn string) error { + data, err := ioutil.ReadFile(fn) + if err != nil { + return fmt.Errorf("unable to read file: %w", err) + } + + for _, init := range capitalizations { + // Match the title-cased capitalization target, asserting that its followed by + // either a capital letter, whitespace, a digit, or the end of text. + // This is to avoid, e.g., turning "Identifier" into "IDentifier". + re := regexp.MustCompile(strings.Title(strings.ToLower(init)) + `([A-Z\s\d]|$)`) + // RE2 does not support zero-width lookahead assertions, so we have to replace + // the last character that may have matched the first capture group in the + // expression constructed above. + data = re.ReplaceAll(data, []byte(init+`$1`)) + } + + for cur, repl := range replacements { + data = bytes.ReplaceAll(data, []byte(cur), []byte(repl)) + } + + err = ioutil.WriteFile(fn, data, 0644) + if err != nil { + return fmt.Errorf("unable to write updated file: %w", err) + } + + return nil +} + +func format(fn string) error { + cmd := exec.Command("gofmt", "-w", "-s", fn) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + return fmt.Errorf("unable to format updated file: %w", err) + } + + return nil +} diff --git a/internal/tools/semconv-gen/template.j2 b/internal/tools/semconv-gen/template.j2 new file mode 100644 index 00000000000..63095e3b19c --- /dev/null +++ b/internal/tools/semconv-gen/template.j2 @@ -0,0 +1,76 @@ +{%- macro to_go_attr_type(type, val) -%} + {%- if type == "string" -%} + String("{{val}}") + {%- elif type == "int" -%} + Int({{val}}) + {%- endif -%} +{%- endmacro -%} +{%- macro to_go_name(fqn) -%} +{{fqn | replace(".", " ") | replace("_", " ") | title | replace(" ", "")}} +{%- endmacro -%} +{%- macro godoc(attr) -%} +{{ attr.brief }} +// +{%- if attr.attr_type is string %} +Type: {{ attr.attr_type }} +{%- else %} +Type: Enum +{%- endif %} +{%- if attr.required == Required.ALWAYS %} +Required: Always +{%- elif attr.required == Required.CONDITIONAL %} +Required: {{ attr.required_msg }} +{%- else %} +Required: No +{%- endif %} +{%- if attr.examples is iterable %} +Examples: {{ attr.examples | pprint | trim("[]") }} +{%- endif %} +{%- if attr.note %} +Note: {{ attr.note }} +{%- endif %} +{%- endmacro -%} +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated from semantic convention specification. DO NOT EDIT. + +package semconv // import "go.opentelemetry.io/otel/semconv" + +import "go.opentelemetry.io/otel/attribute" + +{% for semconv in semconvs -%} +{%- if semconvs[semconv].attributes | rejectattr("ref") | selectattr("is_local") | sort(attribute=fqn) | length > 0 -%} +// {{ semconvs[semconv].brief }} +const ( +{% for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%} + // {{ godoc(attr) | wordwrap | indent(3) | replace(" ", "\t// ") | replace("// //", "//") }} + {{to_go_name(attr.fqn)}}Key = attribute.Key("{{attr.fqn}}") +{% endfor %} +) +{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%} +{%- if attr.attr_type is not string %} + +var ( +{%- for val in attr.attr_type.members %} + // {{ val.brief | to_doc_brief }} + {{to_go_name("{}.{}".format(attr.fqn, val.member_id))}} = {{to_go_name(attr.fqn)}}Key.{{to_go_attr_type(attr.attr_type.enum_type, val.value)}} +{%- endfor %} +) +{%- endif -%} +{%- endfor %} + +{% endif %} +{% endfor -%} + diff --git a/semconv/exception.go b/semconv/exception.go index 97002611228..ee13cfdbdfe 100644 --- a/semconv/exception.go +++ b/semconv/exception.go @@ -11,27 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -package semconv - -import "go.opentelemetry.io/otel/attribute" - -// Semantic conventions for exception attribute keys. -const ( - // The Go type containing the error or exception. - ExceptionTypeKey = attribute.Key("exception.type") - // The exception message. - ExceptionMessageKey = attribute.Key("exception.message") - - // A stacktrace as a string. This most commonly will come from - // "runtime/debug".Stack. - ExceptionStacktraceKey = attribute.Key("exception.stacktrace") - - // If the exception event is recorded at a point where it is known - // that the exception is escaping the scope of the span this - // attribute is set to true. - ExceptionEscapedKey = attribute.Key("exception.escaped") -) +package semconv const ( // ExceptionEventName is the name of the Span event representing an exception. diff --git a/semconv/http.go b/semconv/http.go index d8160f92425..b80707981a2 100644 --- a/semconv/http.go +++ b/semconv/http.go @@ -25,6 +25,11 @@ import ( "go.opentelemetry.io/otel/codes" ) +var ( + HTTPSchemeHTTP = HTTPSchemeKey.String("http") + HTTPSchemeHTTPS = HTTPSchemeKey.String("https") +) + // 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 diff --git a/semconv/http_test.go b/semconv/http_test.go index 075baaa79a9..91068442e15 100644 --- a/semconv/http_test.go +++ b/semconv/http_test.go @@ -63,7 +63,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), }, }, { @@ -79,7 +79,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.UDP"), + attribute.String("net.transport", "ip_udp"), }, }, { @@ -95,7 +95,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP"), + attribute.String("net.transport", "ip"), }, }, { @@ -111,7 +111,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "Unix"), + attribute.String("net.transport", "unix"), }, }, { @@ -143,7 +143,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), }, @@ -161,7 +161,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.name", "example.com"), attribute.Int("net.peer.port", 56), }, @@ -179,7 +179,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), }, }, @@ -196,7 +196,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.name", "example.com"), }, }, @@ -213,7 +213,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), }, }, { @@ -229,7 +229,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), attribute.String("net.host.name", "example.com"), @@ -248,7 +248,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), attribute.String("net.host.ip", "4.3.2.1"), @@ -267,7 +267,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), attribute.String("net.host.name", "example.com"), @@ -287,7 +287,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), attribute.String("net.host.ip", "4.3.2.1"), @@ -307,7 +307,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), attribute.String("net.host.name", "example.com"), @@ -326,7 +326,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), attribute.String("net.host.ip", "4.3.2.1"), @@ -345,7 +345,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), }, @@ -365,7 +365,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { "Host": []string{"4.3.2.1:78"}, }, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), attribute.String("net.host.ip", "4.3.2.1"), @@ -386,7 +386,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) { }, header: nil, expected: []attribute.KeyValue{ - attribute.String("net.transport", "IP.TCP"), + attribute.String("net.transport", "ip_tcp"), attribute.String("net.peer.ip", "1.2.3.4"), attribute.Int("net.peer.port", 56), attribute.String("net.host.ip", "4.3.2.1"), diff --git a/semconv/resource.go b/semconv/resource.go index 426ddd70c8e..d1edb3af400 100644 --- a/semconv/resource.go +++ b/semconv/resource.go @@ -12,246 +12,763 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Code generated from semantic convention specification. DO NOT EDIT. + package semconv // import "go.opentelemetry.io/otel/semconv" import "go.opentelemetry.io/otel/attribute" -// Semantic conventions for service resource attribute keys. +// A cloud environment (e.g. GCP, Azure, AWS) const ( - // Name of the service. - ServiceNameKey = attribute.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 = attribute.Key("service.namespace") + // Name of the cloud provider. + // + // Type: Enum + // Required: No + // Examples: 'gcp' + CloudProviderKey = attribute.Key("cloud.provider") + // The cloud account ID the resource is assigned to. + // + // Type: string + // Required: No + // Examples: '111111111111', 'opentelemetry' + CloudAccountIDKey = attribute.Key("cloud.account.id") + // The geographical region the resource is running. Refer to your provider's docs + // to see the available regions, for example [AWS + // regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), + // [Azure regions](https://azure.microsoft.com/en-us/global- + // infrastructure/geographies/), or [Google Cloud + // regions](https://cloud.google.com/about/locations). + // + // Type: string + // Required: No + // Examples: 'us-central1', 'us-east-1' + CloudRegionKey = attribute.Key("cloud.region") + // Cloud regions often have multiple, isolated locations known as zones to + // increase availability. Availability zone represents the zone where the resource + // is running. + // + // Type: string + // Required: No + // Examples: 'us-east-1c' + // Note: Availability zones are called "zones" on Google Cloud. + CloudAvailabilityZoneKey = attribute.Key("cloud.availability_zone") + // The cloud platform in use. + // + // Type: Enum + // Required: No + // Examples: 'aws_ec2', 'azure_vm', 'gcp_compute_engine' + // Note: The prefix of the service SHOULD match the one specified in + // `cloud.provider`. + CloudPlatformKey = attribute.Key("cloud.platform") +) - // A unique identifier of the service instance. In conjunction with the - // `service.name` and `service.namespace` this must be unique. - ServiceInstanceIDKey = attribute.Key("service.instance.id") +var ( + // Amazon Web Services + CloudProviderAWS = CloudProviderKey.String("aws") + // Microsoft Azure + CloudProviderAzure = CloudProviderKey.String("azure") + // Google Cloud Platform + CloudProviderGCP = CloudProviderKey.String("gcp") +) - // The version of the service API. - ServiceVersionKey = attribute.Key("service.version") +var ( + // AWS Elastic Compute Cloud + CloudPlatformAWSEC2 = CloudPlatformKey.String("aws_ec2") + // AWS Elastic Container Service + CloudPlatformAWSECS = CloudPlatformKey.String("aws_ecs") + // AWS Elastic Kubernetes Service + CloudPlatformAWSEKS = CloudPlatformKey.String("aws_eks") + // AWS Lambda + CloudPlatformAWSLambda = CloudPlatformKey.String("aws_lambda") + // AWS Elastic Beanstalk + CloudPlatformAWSElasticBeanstalk = CloudPlatformKey.String("aws_elastic_beanstalk") + // Azure Virtual Machines + CloudPlatformAzureVM = CloudPlatformKey.String("azure_vm") + // Azure Container Instances + CloudPlatformAzureContainerInstances = CloudPlatformKey.String("azure_container_instances") + // Azure Kubernetes Service + CloudPlatformAzureAKS = CloudPlatformKey.String("azure_aks") + // Azure Functions + CloudPlatformAzureFunctions = CloudPlatformKey.String("azure_functions") + // Azure App Service + CloudPlatformAzureAppService = CloudPlatformKey.String("azure_app_service") + // Google Cloud Compute Engine (GCE) + CloudPlatformGCPComputeEngine = CloudPlatformKey.String("gcp_compute_engine") + // Google Cloud Run + CloudPlatformGCPCloudRun = CloudPlatformKey.String("gcp_cloud_run") + // Google Cloud Kubernetes Engine (GKE) + CloudPlatformGCPKubernetesEngine = CloudPlatformKey.String("gcp_kubernetes_engine") + // Google Cloud Functions (GCF) + CloudPlatformGCPCloudFunctions = CloudPlatformKey.String("gcp_cloud_functions") + // Google Cloud App Engine (GAE) + CloudPlatformGCPAppEngine = CloudPlatformKey.String("gcp_app_engine") ) -// Semantic conventions for telemetry SDK resource attribute keys. +// Resources used by AWS Elastic Container Service (ECS). const ( - // The name of the telemetry SDK. + // The Amazon Resource Name (ARN) of an [ECS container instance](https://docs.aws. + // amazon.com/AmazonECS/latest/developerguide/ECS_instances.html). // - // The default OpenTelemetry SDK provided by the OpenTelemetry project - // MUST set telemetry.sdk.name to the value `opentelemetry`. + // Type: string + // Required: No + // Examples: 'arn:aws:ecs:us- + // west-1:123456789123:container/32624152-9086-4f0e-acae-1a75b14fe4d9' + AWSECSContainerARNKey = attribute.Key("aws.ecs.container.arn") + // The ARN of an [ECS cluster](https://docs.aws.amazon.com/AmazonECS/latest/develo + // perguide/clusters.html). // - // If another SDK is used, this attribute MUST be set to the import path - // of that SDK's package. + // Type: string + // Required: No + // Examples: 'arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster' + AWSECSClusterARNKey = attribute.Key("aws.ecs.cluster.arn") + // The [launch type](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/l + // aunch_types.html) for an ECS task. // - // The value `opentelemetry` is reserved and MUST NOT be used by - // non-OpenTelemetry SDKs. - TelemetrySDKNameKey = attribute.Key("telemetry.sdk.name") + // Type: Enum + // Required: No + // Examples: 'ec2', 'fargate' + AWSECSLaunchtypeKey = attribute.Key("aws.ecs.launchtype") + // The ARN of an [ECS task definition](https://docs.aws.amazon.com/AmazonECS/lates + // t/developerguide/task_definitions.html). + // + // Type: string + // Required: No + // Examples: 'arn:aws:ecs:us- + // west-1:123456789123:task/10838bed-421f-43ef-870a-f43feacbbb5b' + AWSECSTaskARNKey = attribute.Key("aws.ecs.task.arn") + // The task definition family this task definition is a member of. + // + // Type: string + // Required: No + // Examples: 'opentelemetry-family' + AWSECSTaskFamilyKey = attribute.Key("aws.ecs.task.family") + // The revision for this task definition. + // + // Type: string + // Required: No + // Examples: '8', '26' + AWSECSTaskRevisionKey = attribute.Key("aws.ecs.task.revision") +) - // The language of the telemetry SDK. - TelemetrySDKLanguageKey = attribute.Key("telemetry.sdk.language") +var ( + // ec2 + AWSECSLaunchtypeEC2 = AWSECSLaunchtypeKey.String("ec2") + // fargate + AWSECSLaunchtypeFargate = AWSECSLaunchtypeKey.String("fargate") +) - // The version string of the telemetry SDK. - TelemetrySDKVersionKey = attribute.Key("telemetry.sdk.version") +// Resources used by AWS Elastic Kubernetes Service (EKS). +const ( + // The ARN of an EKS cluster. + // + // Type: string + // Required: No + // Examples: 'arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster' + AWSEKSClusterARNKey = attribute.Key("aws.eks.cluster.arn") ) -// Semantic conventions for telemetry SDK resource attributes. -var ( - TelemetrySDKLanguageGo = TelemetrySDKLanguageKey.String("go") +// Resources specific to Amazon Web Services. +const ( + // The name(s) of the AWS log group(s) an application is writing to. + // + // Type: string[] + // Required: No + // Examples: '/aws/lambda/my-function', 'opentelemetry-service' + // Note: Multiple log groups must be supported for cases like multi-container + // applications, where a single application has sidecar containers, and each write + // to their own log group. + AWSLogGroupNamesKey = attribute.Key("aws.log.group.names") + // The Amazon Resource Name(s) (ARN) of the AWS log group(s). + // + // Type: string[] + // Required: No + // Examples: 'arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:*' + // Note: See the [log group ARN format + // documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam- + // access-control-overview-cwl.html#CWL_ARN_Format). + AWSLogGroupARNsKey = attribute.Key("aws.log.group.arns") + // The name(s) of the AWS log stream(s) an application is writing to. + // + // Type: string[] + // Required: No + // Examples: 'logs/main/10838bed-421f-43ef-870a-f43feacbbb5b' + AWSLogStreamNamesKey = attribute.Key("aws.log.stream.names") + // The ARN(s) of the AWS log stream(s). + // + // Type: string[] + // Required: No + // Examples: 'arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:log- + // stream:logs/main/10838bed-421f-43ef-870a-f43feacbbb5b' + // Note: See the [log stream ARN format + // documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam- + // access-control-overview-cwl.html#CWL_ARN_Format). One log group can contain + // several log streams, so these ARNs necessarily identify both a log group and a + // log stream. + AWSLogStreamARNsKey = attribute.Key("aws.log.stream.arns") ) -// Semantic conventions for container resource attribute keys. +// A container instance. const ( - // A uniquely identifying name for the Container. + // Container name. + // + // Type: string + // Required: No + // Examples: 'opentelemetry-autoconf' ContainerNameKey = attribute.Key("container.name") - - // Container ID, usually a UUID, as for example used to - // identify Docker containers. The UUID might be abbreviated. + // Container ID. Usually a UUID, as for example used to [identify Docker + // containers](https://docs.docker.com/engine/reference/run/#container- + // identification). The UUID might be abbreviated. + // + // Type: string + // Required: No + // Examples: 'a3bf90e006b2' ContainerIDKey = attribute.Key("container.id") - + // The container runtime managing this container. + // + // Type: string + // Required: No + // Examples: 'docker', 'containerd', 'rkt' + ContainerRuntimeKey = attribute.Key("container.runtime") // Name of the image the container was built on. + // + // Type: string + // Required: No + // Examples: 'gcr.io/opentelemetry/operator' ContainerImageNameKey = attribute.Key("container.image.name") - // Container image tag. + // + // Type: string + // Required: No + // Examples: '0.1' ContainerImageTagKey = attribute.Key("container.image.tag") ) -// Semantic conventions for Function-as-a-Service resource attribute keys. +// The software deployment. const ( - // A uniquely identifying name for the FaaS. - FaaSNameKey = attribute.Key("faas.name") + // Name of the [deployment + // environment](https://en.wikipedia.org/wiki/Deployment_environment) (aka + // deployment tier). + // + // Type: string + // Required: No + // Examples: 'staging', 'production' + DeploymentEnvironmentKey = attribute.Key("deployment.environment") +) - // The unique name of the function being executed. +// A serverless instance. +const ( + // The name of the function being executed. + // + // Type: string + // Required: Always + // Examples: 'my-function' + FaaSNameKey = attribute.Key("faas.name") + // The unique ID of the function being executed. + // + // Type: string + // Required: Always + // Examples: 'arn:aws:lambda:us-west-2:123456789012:function:my-function' + // Note: For example, in AWS Lambda this field corresponds to the + // [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and- + // namespaces.html) value, in GCP to the URI of the resource, and in Azure to the + // [FunctionDirectory](https://github.com/Azure/azure-functions- + // host/wiki/Retrieving-information-about-the-currently-running-function) field. FaaSIDKey = attribute.Key("faas.id") - - // The version of the function being executed. + // The version string of the function being executed as defined in [Version + // Attributes](../../resource/semantic_conventions/README.md#version-attributes). + // + // Type: string + // Required: No + // Examples: '2.0.0' FaaSVersionKey = attribute.Key("faas.version") - - // The execution environment identifier. + // The execution environment ID as a string. + // + // Type: string + // Required: No + // Examples: 'my-function:instance-0001' FaaSInstanceKey = attribute.Key("faas.instance") + // The amount of memory available to the serverless function in MiB. + // + // Type: int + // Required: No + // Examples: 128 + // Note: It's recommended to set this attribute since e.g. too little memory can + // easily stop a Java AWS Lambda function from working correctly. On AWS Lambda, + // the environment variable `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` provides this + // information. + FaaSMaxMemoryKey = attribute.Key("faas.max_memory") ) -// Semantic conventions for operating system process resource attribute keys. +// A host is defined as a general computing instance. const ( - // Process identifier (PID). - ProcessPIDKey = attribute.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 = attribute.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 = attribute.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 = attribute.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 = attribute.Key("process.command_line") - // All the command arguments (including the command/executable itself) - // as received by the process. On Linux-based systems (and some other - // Unixoid systems supporting procfs), can be set according to the list - // of null-delimited strings extracted from `proc/[pid]/cmdline`. For - // libc-based executables, this would be the full argv vector passed to - // `main`. - ProcessCommandArgsKey = attribute.Key("process.command_args") - // The username of the user that owns the process. - ProcessOwnerKey = attribute.Key("process.owner") - // The name of the runtime of this process. For compiled native - // binaries, this SHOULD be the name of the compiler. - ProcessRuntimeNameKey = attribute.Key("process.runtime.name") - // The version of the runtime of this process, as returned by the - // runtime without modification. - ProcessRuntimeVersionKey = attribute.Key("process.runtime.version") - // An additional description about the runtime of the process, for - // example a specific vendor customization of the runtime environment. - ProcessRuntimeDescriptionKey = attribute.Key("process.runtime.description") + // Unique host ID. For Cloud, this must be the instance_id assigned by the cloud + // provider. + // + // Type: string + // Required: No + // Examples: 'opentelemetry-test' + HostIDKey = attribute.Key("host.id") + // Name of the host. On Unix systems, it may contain what the hostname command + // returns, or the fully qualified hostname, or another name specified by the + // user. + // + // Type: string + // Required: No + // Examples: 'opentelemetry-test' + HostNameKey = attribute.Key("host.name") + // Type of host. For Cloud, this must be the machine type. + // + // Type: string + // Required: No + // Examples: 'n1-standard-1' + HostTypeKey = attribute.Key("host.type") + // The CPU architecture the host system is running on. + // + // Type: Enum + // Required: No + HostArchKey = attribute.Key("host.arch") + // Name of the VM image or OS install the host was instantiated from. + // + // Type: string + // Required: No + // Examples: 'infra-ami-eks-worker-node-7d4ec78312', 'CentOS-8-x86_64-1905' + HostImageNameKey = attribute.Key("host.image.name") + // VM image ID. For Cloud, this value is from the provider. + // + // Type: string + // Required: No + // Examples: 'ami-07b06b442921831e5' + HostImageIDKey = attribute.Key("host.image.id") + // The version string of the VM image as defined in [Version + // Attributes](README.md#version-attributes). + // + // Type: string + // Required: No + // Examples: '0.1' + HostImageVersionKey = attribute.Key("host.image.version") +) + +var ( + // AMD64 + HostArchAMD64 = HostArchKey.String("amd64") + // ARM32 + HostArchARM32 = HostArchKey.String("arm32") + // ARM64 + HostArchARM64 = HostArchKey.String("arm64") + // Itanium + HostArchIA64 = HostArchKey.String("ia64") + // 32-bit PowerPC + HostArchPPC32 = HostArchKey.String("ppc32") + // 64-bit PowerPC + HostArchPPC64 = HostArchKey.String("ppc64") + // 32-bit x86 + HostArchX86 = HostArchKey.String("x86") ) -// Semantic conventions for Kubernetes resource attribute keys. +// A Kubernetes Cluster. 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 attribute. + // The name of the cluster. + // + // Type: string + // Required: No + // Examples: 'opentelemetry-cluster' K8SClusterNameKey = attribute.Key("k8s.cluster.name") +) +// A Kubernetes Node object. +const ( // The name of the Node. + // + // Type: string + // Required: No + // Examples: 'node-1' K8SNodeNameKey = attribute.Key("k8s.node.name") - // The UID of the Node. + // + // Type: string + // Required: No + // Examples: '1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2' K8SNodeUIDKey = attribute.Key("k8s.node.uid") +) +// A Kubernetes Namespace. +const ( // The name of the namespace that the pod is running in. + // + // Type: string + // Required: No + // Examples: 'default' K8SNamespaceNameKey = attribute.Key("k8s.namespace.name") +) - // The uid of the Pod. +// A Kubernetes Pod object. +const ( + // The UID of the Pod. + // + // Type: string + // Required: No + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SPodUIDKey = attribute.Key("k8s.pod.uid") - - // The name of the pod. + // The name of the Pod. + // + // Type: string + // Required: No + // Examples: 'opentelemetry-pod-autoconf' K8SPodNameKey = attribute.Key("k8s.pod.name") +) +// A container in a [PodTemplate](https://kubernetes.io/docs/concepts/workloads/pods/#pod-templates). +const ( // The name of the Container in a Pod template. + // + // Type: string + // Required: No + // Examples: 'redis' K8SContainerNameKey = attribute.Key("k8s.container.name") +) - // The uid of the ReplicaSet. - K8SReplicaSetUIDKey = attribute.Key("k8s.replicaset.uid") - +// A Kubernetes ReplicaSet object. +const ( + // The UID of the ReplicaSet. + // + // Type: string + // Required: No + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SReplicasetUIDKey = attribute.Key("k8s.replicaset.uid") // The name of the ReplicaSet. - K8SReplicaSetNameKey = attribute.Key("k8s.replicaset.name") + // + // Type: string + // Required: No + // Examples: 'opentelemetry' + K8SReplicasetNameKey = attribute.Key("k8s.replicaset.name") +) - // The uid of the Deployment. +// A Kubernetes Deployment object. +const ( + // The UID of the Deployment. + // + // Type: string + // Required: No + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SDeploymentUIDKey = attribute.Key("k8s.deployment.uid") - - // The name of the deployment. + // The name of the Deployment. + // + // Type: string + // Required: No + // Examples: 'opentelemetry' K8SDeploymentNameKey = attribute.Key("k8s.deployment.name") +) - // The uid of the StatefulSet. - K8SStatefulSetUIDKey = attribute.Key("k8s.statefulset.uid") - +// A Kubernetes StatefulSet object. +const ( + // The UID of the StatefulSet. + // + // Type: string + // Required: No + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SStatefulsetUIDKey = attribute.Key("k8s.statefulset.uid") // The name of the StatefulSet. - K8SStatefulSetNameKey = attribute.Key("k8s.statefulset.name") - - // The uid of the DaemonSet. - K8SDaemonSetUIDKey = attribute.Key("k8s.daemonset.uid") + // + // Type: string + // Required: No + // Examples: 'opentelemetry' + K8SStatefulsetNameKey = attribute.Key("k8s.statefulset.name") +) +// A Kubernetes DaemonSet object. +const ( + // The UID of the DaemonSet. + // + // Type: string + // Required: No + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SDaemonsetUIDKey = attribute.Key("k8s.daemonset.uid") // The name of the DaemonSet. - K8SDaemonSetNameKey = attribute.Key("k8s.daemonset.name") + // + // Type: string + // Required: No + // Examples: 'opentelemetry' + K8SDaemonsetNameKey = attribute.Key("k8s.daemonset.name") +) - // The uid of the Job. +// A Kubernetes Job object. +const ( + // The UID of the Job. + // + // Type: string + // Required: No + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SJobUIDKey = attribute.Key("k8s.job.uid") - // The name of the Job. + // + // Type: string + // Required: No + // Examples: 'opentelemetry' K8SJobNameKey = attribute.Key("k8s.job.name") +) - // The uid of the CronJob. +// A Kubernetes CronJob object. +const ( + // The UID of the CronJob. + // + // Type: string + // Required: No + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SCronJobUIDKey = attribute.Key("k8s.cronjob.uid") - // The name of the CronJob. + // + // Type: string + // Required: No + // Examples: 'opentelemetry' K8SCronJobNameKey = attribute.Key("k8s.cronjob.name") ) -// Semantic conventions for OS resource attribute keys. +// The operating system (OS) on which the process represented by this resource is running. const ( // The operating system type. + // + // Type: Enum + // Required: Always OSTypeKey = attribute.Key("os.type") - // Human readable (not intended to be parsed) OS version information. + // Human readable (not intended to be parsed) OS version information, like e.g. + // reported by `ver` or `lsb_release -a` commands. + // + // Type: string + // Required: No + // Examples: 'Microsoft Windows [Version 10.0.18363.778]', 'Ubuntu 18.04.1 LTS' OSDescriptionKey = attribute.Key("os.description") ) -// Semantic conventions for host resource attribute keys. -const ( - // A uniquely identifying name for the host: 'hostname', FQDN, or user specified name - HostNameKey = attribute.Key("host.name") - - // Unique host ID. For cloud environments this will be the instance ID. - HostIDKey = attribute.Key("host.id") - - // Type of host. For cloud environments this will be the machine type. - HostTypeKey = attribute.Key("host.type") - - // Name of the OS or VM image the host is running. - HostImageNameKey = attribute.Key("host.image.name") - - // Identifier of the image the host is running. - HostImageIDKey = attribute.Key("host.image.id") - - // Version of the image the host is running. - HostImageVersionKey = attribute.Key("host.image.version") +var ( + // Microsoft Windows + OSTypeWindows = OSTypeKey.String("windows") + // Linux + OSTypeLinux = OSTypeKey.String("linux") + // Apple Darwin + OSTypeDarwin = OSTypeKey.String("darwin") + // FreeBSD + OSTypeFreeBSD = OSTypeKey.String("freebsd") + // NetBSD + OSTypeNetBSD = OSTypeKey.String("netbsd") + // OpenBSD + OSTypeOpenBSD = OSTypeKey.String("openbsd") + // DragonFly BSD + OSTypeDragonflyBSD = OSTypeKey.String("dragonflybsd") + // HP-UX (Hewlett Packard Unix) + OSTypeHPUX = OSTypeKey.String("hpux") + // AIX (Advanced Interactive eXecutive) + OSTypeAIX = OSTypeKey.String("aix") + // Oracle Solaris + OSTypeSolaris = OSTypeKey.String("solaris") + // IBM z/OS + OSTypeZOS = OSTypeKey.String("z_os") ) -// Semantic conventions for cloud environment resource attribute keys. +// An operating system process. const ( - // Name of the cloud provider. - CloudProviderKey = attribute.Key("cloud.provider") + // Process identifier (PID). + // + // Type: int + // Required: No + // Examples: 1234 + ProcessPIDKey = attribute.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`. + // + // Type: string + // Required: See below + // Examples: 'otelcol' + ProcessExecutableNameKey = attribute.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`. + // + // Type: string + // Required: See below + // Examples: '/usr/bin/cmd/otelcol' + ProcessExecutablePathKey = attribute.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`. + // + // Type: string + // Required: See below + // Examples: 'cmd/otelcol' + ProcessCommandKey = attribute.Key("process.command") + // The full command used to launch the process as a single string representing the + // full command. On Windows, can be set to the result of `GetCommandLineW`. Do not + // set this if you have to assemble it just for monitoring; use + // `process.command_args` instead. + // + // Type: string + // Required: See below + // Examples: 'C:\\cmd\\otecol --config="my directory\\config.yaml"' + ProcessCommandLineKey = attribute.Key("process.command_line") + // All the command arguments (including the command/executable itself) as received + // by the process. On Linux-based systems (and some other Unixoid systems + // supporting procfs), can be set according to the list of null-delimited strings + // extracted from `proc/[pid]/cmdline`. For libc-based executables, this would be + // the full argv vector passed to `main`. + // + // Type: string[] + // Required: See below + // Examples: 'cmd/otecol', '--config=config.yaml' + ProcessCommandArgsKey = attribute.Key("process.command_args") + // The username of the user that owns the process. + // + // Type: string + // Required: No + // Examples: 'root' + ProcessOwnerKey = attribute.Key("process.owner") +) - // The account ID from the cloud provider used for authorization. - CloudAccountIDKey = attribute.Key("cloud.account.id") +// The single (language) runtime instance which is monitored. +const ( + // The name of the runtime of this process. For compiled native binaries, this + // SHOULD be the name of the compiler. + // + // Type: string + // Required: No + // Examples: 'OpenJDK Runtime Environment' + ProcessRuntimeNameKey = attribute.Key("process.runtime.name") + // The version of the runtime of this process, as returned by the runtime without + // modification. + // + // Type: string + // Required: No + // Examples: '14.0.2' + ProcessRuntimeVersionKey = attribute.Key("process.runtime.version") + // An additional description about the runtime of the process, for example a + // specific vendor customization of the runtime environment. + // + // Type: string + // Required: No + // Examples: 'Eclipse OpenJ9 Eclipse OpenJ9 VM openj9-0.21.0' + ProcessRuntimeDescriptionKey = attribute.Key("process.runtime.description") +) - // Geographical region where this resource is. - CloudRegionKey = attribute.Key("cloud.region") +// A service instance. +const ( + // Logical name of the service. + // + // Type: string + // Required: Always + // Examples: 'shoppingcart' + // Note: MUST be the same for all instances of horizontally scaled services. If + // the value was not specified, SDKs MUST fallback to `unknown_service:` + // concatenated with [`process.executable.name`](process.md#process), e.g. + // `unknown_service:bash`. If `process.executable.name` is not available, the + // value MUST be set to `unknown_service`. + ServiceNameKey = attribute.Key("service.name") + // A namespace for `service.name`. + // + // Type: string + // Required: No + // Examples: 'Shop' + // Note: A string value having a 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. If + // `service.namespace` is not specified in the Resource then `service.name` is + // expected to be unique for all services that have no explicit namespace defined + // (so the empty/unspecified namespace is simply one more valid namespace). Zero- + // length namespace string is assumed equal to unspecified namespace. + ServiceNamespaceKey = attribute.Key("service.namespace") + // The string ID of the service instance. + // + // Type: string + // Required: No + // Examples: '627cc493-f310-47de-96bd-71410b7dec09' + // Note: MUST be unique for each instance of the same + // `service.namespace,service.name` pair (in other words + // `service.namespace,service.name,service.instance.id` triplet MUST be globally + // unique). The ID helps to distinguish instances of the same service that exist + // at the same time (e.g. instances of a horizontally scaled service). It is + // preferable for the ID to be persistent and stay the same for the lifetime of + // the service instance, however it is acceptable that the ID is ephemeral and + // changes during important lifetime events for the service (e.g. service + // restarts). If the service has no inherent unique ID that can be used as the + // value of this attribute it is recommended to generate a random Version 1 or + // Version 4 RFC 4122 UUID (services aiming for reproducible UUIDs may also use + // Version 5, see RFC 4122 for more recommendations). + ServiceInstanceIDKey = attribute.Key("service.instance.id") + // The version string of the service API or implementation. + // + // Type: string + // Required: No + // Examples: '2.0.0' + ServiceVersionKey = attribute.Key("service.version") +) - // Availability zone of the region where this resource is. - CloudAvailabilityZoneKey = attribute.Key("cloud.availability_zone") +// The telemetry SDK used to capture data recorded by the instrumentation libraries. +const ( + // The name of the telemetry SDK as defined above. + // + // Type: string + // Required: No + // Examples: 'opentelemetry' + TelemetrySDKNameKey = attribute.Key("telemetry.sdk.name") + // The language of the telemetry SDK. + // + // Type: Enum + // Required: No + TelemetrySDKLanguageKey = attribute.Key("telemetry.sdk.language") + // The version string of the telemetry SDK. + // + // Type: string + // Required: No + // Examples: '1.2.3' + TelemetrySDKVersionKey = attribute.Key("telemetry.sdk.version") + // The version string of the auto instrumentation agent, if used. + // + // Type: string + // Required: No + // Examples: '1.2.3' + TelemetryAutoVersionKey = attribute.Key("telemetry.auto.version") ) -// Semantic conventions for common cloud provider resource attributes. var ( - CloudProviderAWS = CloudProviderKey.String("aws") - CloudProviderAzure = CloudProviderKey.String("azure") - CloudProviderGCP = CloudProviderKey.String("gcp") + // cpp + TelemetrySDKLanguageCpp = TelemetrySDKLanguageKey.String("cpp") + // dotnet + TelemetrySDKLanguageDotnet = TelemetrySDKLanguageKey.String("dotnet") + // erlang + TelemetrySDKLanguageErlang = TelemetrySDKLanguageKey.String("erlang") + // go + TelemetrySDKLanguageGo = TelemetrySDKLanguageKey.String("go") + // java + TelemetrySDKLanguageJava = TelemetrySDKLanguageKey.String("java") + // nodejs + TelemetrySDKLanguageNodejs = TelemetrySDKLanguageKey.String("nodejs") + // php + TelemetrySDKLanguagePHP = TelemetrySDKLanguageKey.String("php") + // python + TelemetrySDKLanguagePython = TelemetrySDKLanguageKey.String("python") + // ruby + TelemetrySDKLanguageRuby = TelemetrySDKLanguageKey.String("ruby") + // webjs + TelemetrySDKLanguageWebjs = TelemetrySDKLanguageKey.String("webjs") ) -// Semantic conventions for deployment attributes. +// Resource describing the packaged software running the application code. Web engines are typically executed using process.runtime. const ( - // Name of the deployment environment (aka deployment tier); e.g. (staging, production). - DeploymentEnvironmentKey = attribute.Key("deployment.environment") + // The name of the web engine. + // + // Type: string + // Required: Always + // Examples: 'WildFly' + WebEngineNameKey = attribute.Key("webengine.name") + // The version of the web engine. + // + // Type: string + // Required: No + // Examples: '21.0.0' + WebEngineVersionKey = attribute.Key("webengine.version") + // Additional description of the web engine (e.g. detailed version and edition + // information). + // + // Type: string + // Required: No + // Examples: 'WildFly Full 21.0.0.Final (WildFly Core 13.0.1.Final) - 2.2.2.Final' + WebEngineDescriptionKey = attribute.Key("webengine.description") ) diff --git a/semconv/trace.go b/semconv/trace.go index 145fc607689..45e9280523c 100644 --- a/semconv/trace.go +++ b/semconv/trace.go @@ -12,365 +12,1206 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Code generated from semantic convention specification. DO NOT EDIT. + package semconv // import "go.opentelemetry.io/otel/semconv" import "go.opentelemetry.io/otel/attribute" -// Semantic conventions for attribute keys used for network related -// operations. +// This document defines the attributes used to perform database client calls. const ( - // Transport protocol used. - NetTransportKey = attribute.Key("net.transport") + // An identifier for the database management system (DBMS) product being used. See + // below for a list of well-known identifiers. + // + // Type: Enum + // Required: Always + DBSystemKey = attribute.Key("db.system") + // The connection string used to connect to the database. It is recommended to + // remove embedded credentials. + // + // Type: string + // Required: No + // Examples: 'Server=(localdb)\\v11.0;Integrated Security=true;' + DBConnectionStringKey = attribute.Key("db.connection_string") + // Username for accessing the database. + // + // Type: string + // Required: No + // Examples: 'readonly_user', 'reporting_user' + DBUserKey = attribute.Key("db.user") + // The fully-qualified class name of the [Java Database Connectivity + // (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver + // used to connect. + // + // Type: string + // Required: No + // Examples: 'org.postgresql.Driver', + // 'com.microsoft.sqlserver.jdbc.SQLServerDriver' + DBJDBCDriverClassnameKey = attribute.Key("db.jdbc.driver_classname") + // If no [tech-specific attribute](#call-level-attributes-for-specific- + // technologies) is defined, this attribute is used to report the name of the + // database being accessed. For commands that switch the database, this should be + // set to the target database (even if the command fails). + // + // Type: string + // Required: Required, if applicable and no more-specific attribute is defined. + // Examples: 'customers', 'main' + // Note: In some SQL databases, the database name to be used is called "schema + // name". + DBNameKey = attribute.Key("db.name") + // The database statement being executed. + // + // Type: string + // Required: Required if applicable and not explicitly disabled via + // instrumentation configuration. + // Examples: 'SELECT * FROM wuser_table', 'SET mykey "WuValue"' + // Note: The value may be sanitized to exclude sensitive information. + DBStatementKey = attribute.Key("db.statement") + // The name of the operation being executed, e.g. the [MongoDB command + // name](https://docs.mongodb.com/manual/reference/command/#database-operations) + // such as `findAndModify`, or the SQL keyword. + // + // Type: string + // Required: Required, if `db.statement` is not applicable. + // Examples: 'findAndModify', 'HMSET', 'SELECT' + // Note: When setting this to an SQL keyword, it is not recommended to attempt any + // client-side parsing of `db.statement` just to get this property, but it should + // be set if the operation name is provided by the library being instrumented. If + // the SQL statement has an ambiguous operation, or performs more than one + // operation, this value may be omitted. + DBOperationKey = attribute.Key("db.operation") +) - // Remote address of the peer. - NetPeerIPKey = attribute.Key("net.peer.ip") +var ( + // Some other SQL database. Fallback only. See notes + DBSystemOtherSQL = DBSystemKey.String("other_sql") + // Microsoft SQL Server + DBSystemMSSQL = DBSystemKey.String("mssql") + // MySQL + DBSystemMySQL = DBSystemKey.String("mysql") + // Oracle Database + DBSystemOracle = DBSystemKey.String("oracle") + // IBM DB2 + DBSystemDB2 = DBSystemKey.String("db2") + // PostgreSQL + DBSystemPostgreSQL = DBSystemKey.String("postgresql") + // Amazon Redshift + DBSystemRedshift = DBSystemKey.String("redshift") + // Apache Hive + DBSystemHive = DBSystemKey.String("hive") + // Cloudscape + DBSystemCloudscape = DBSystemKey.String("cloudscape") + // HyperSQL DataBase + DBSystemHSQLDB = DBSystemKey.String("hsqldb") + // Progress Database + DBSystemProgress = DBSystemKey.String("progress") + // SAP MaxDB + DBSystemMaxDB = DBSystemKey.String("maxdb") + // SAP HANA + DBSystemHanaDB = DBSystemKey.String("hanadb") + // Ingres + DBSystemIngres = DBSystemKey.String("ingres") + // FirstSQL + DBSystemFirstSQL = DBSystemKey.String("firstsql") + // EnterpriseDB + DBSystemEDB = DBSystemKey.String("edb") + // InterSystems Caché + DBSystemCache = DBSystemKey.String("cache") + // Adabas (Adaptable Database System) + DBSystemAdabas = DBSystemKey.String("adabas") + // Firebird + DBSystemFirebird = DBSystemKey.String("firebird") + // Apache Derby + DBSystemDerby = DBSystemKey.String("derby") + // FileMaker + DBSystemFilemaker = DBSystemKey.String("filemaker") + // Informix + DBSystemInformix = DBSystemKey.String("informix") + // InstantDB + DBSystemInstantDB = DBSystemKey.String("instantdb") + // InterBase + DBSystemInterbase = DBSystemKey.String("interbase") + // MariaDB + DBSystemMariaDB = DBSystemKey.String("mariadb") + // Netezza + DBSystemNetezza = DBSystemKey.String("netezza") + // Pervasive PSQL + DBSystemPervasive = DBSystemKey.String("pervasive") + // PointBase + DBSystemPointbase = DBSystemKey.String("pointbase") + // SQLite + DBSystemSqlite = DBSystemKey.String("sqlite") + // Sybase + DBSystemSybase = DBSystemKey.String("sybase") + // Teradata + DBSystemTeradata = DBSystemKey.String("teradata") + // Vertica + DBSystemVertica = DBSystemKey.String("vertica") + // H2 + DBSystemH2 = DBSystemKey.String("h2") + // ColdFusion IMQ + DBSystemColdfusion = DBSystemKey.String("coldfusion") + // Apache Cassandra + DBSystemCassandra = DBSystemKey.String("cassandra") + // Apache HBase + DBSystemHBase = DBSystemKey.String("hbase") + // MongoDB + DBSystemMongoDB = DBSystemKey.String("mongodb") + // Redis + DBSystemRedis = DBSystemKey.String("redis") + // Couchbase + DBSystemCouchbase = DBSystemKey.String("couchbase") + // CouchDB + DBSystemCouchDB = DBSystemKey.String("couchdb") + // Microsoft Azure Cosmos DB + DBSystemCosmosDB = DBSystemKey.String("cosmosdb") + // Amazon DynamoDB + DBSystemDynamoDB = DBSystemKey.String("dynamodb") + // Neo4j + DBSystemNeo4j = DBSystemKey.String("neo4j") + // Apache Geode + DBSystemGeode = DBSystemKey.String("geode") + // Elasticsearch + DBSystemElasticsearch = DBSystemKey.String("elasticsearch") +) + +// Connection-level attributes for Microsoft SQL Server +const ( + // The Microsoft SQL Server [instance name](https://docs.microsoft.com/en- + // us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) + // connecting to. This name is used to determine the port of a named instance. + // + // Type: string + // Required: No + // Examples: 'MSSQLSERVER' + // Note: If setting a `db.mssql.instance_name`, `net.peer.port` is no longer + // required (but still recommended if non-standard). + DBMSSQLInstanceNameKey = attribute.Key("db.mssql.instance_name") +) + +// Call-level attributes for Cassandra +const ( + // The name of the keyspace being accessed. To be used instead of the generic + // `db.name` attribute. + // + // Type: string + // Required: Always + // Examples: 'mykeyspace' + DBCassandraKeyspaceKey = attribute.Key("db.cassandra.keyspace") + // The fetch size used for paging, i.e. how many rows will be returned at once. + // + // Type: int + // Required: No + // Examples: 5000 + DBCassandraPageSizeKey = attribute.Key("db.cassandra.page_size") + // The consistency level of the query. Based on consistency values from + // [CQL](https://docs.datastax.com/en/cassandra- + // oss/3.0/cassandra/dml/dmlConfigConsistency.html). + // + // Type: Enum + // Required: No + DBCassandraConsistencyLevelKey = attribute.Key("db.cassandra.consistency_level") + // The name of the primary table that the operation is acting upon, including the + // schema name (if applicable). + // + // Type: string + // Required: Recommended if available. + // Examples: 'mytable' + // Note: This mirrors the db.sql.table attribute but references cassandra rather + // than sql. It is not recommended to attempt any client-side parsing of + // `db.statement` just to get this property, but it should be set if it is + // provided by the library being instrumented. If the operation is acting upon an + // anonymous table, or more than one table, this value MUST NOT be set. + DBCassandraTableKey = attribute.Key("db.cassandra.table") + // Whether or not the query is idempotent. + // + // Type: boolean + // Required: No + DBCassandraIdempotenceKey = attribute.Key("db.cassandra.idempotence") + // The number of times a query was speculatively executed. Not set or `0` if the + // query was not executed speculatively. + // + // Type: int + // Required: No + // Examples: 0, 2 + DBCassandraSpeculativeExecutionCountKey = attribute.Key("db.cassandra.speculative_execution_count") + // The ID of the coordinating node for a query. + // + // Type: string + // Required: No + // Examples: 'be13faa2-8574-4d71-926d-27f16cf8a7af' + DBCassandraCoordinatorIDKey = attribute.Key("db.cassandra.coordinator.id") + // The data center of the coordinating node for a query. + // + // Type: string + // Required: No + // Examples: 'us-west-2' + DBCassandraCoordinatorDCKey = attribute.Key("db.cassandra.coordinator.dc") +) + +var ( + // all + DBCassandraConsistencyLevelAll = DBCassandraConsistencyLevelKey.String("all") + // each_quorum + DBCassandraConsistencyLevelEachQuorum = DBCassandraConsistencyLevelKey.String("each_quorum") + // quorum + DBCassandraConsistencyLevelQuorum = DBCassandraConsistencyLevelKey.String("quorum") + // local_quorum + DBCassandraConsistencyLevelLocalQuorum = DBCassandraConsistencyLevelKey.String("local_quorum") + // one + DBCassandraConsistencyLevelOne = DBCassandraConsistencyLevelKey.String("one") + // two + DBCassandraConsistencyLevelTwo = DBCassandraConsistencyLevelKey.String("two") + // three + DBCassandraConsistencyLevelThree = DBCassandraConsistencyLevelKey.String("three") + // local_one + DBCassandraConsistencyLevelLocalOne = DBCassandraConsistencyLevelKey.String("local_one") + // any + DBCassandraConsistencyLevelAny = DBCassandraConsistencyLevelKey.String("any") + // serial + DBCassandraConsistencyLevelSerial = DBCassandraConsistencyLevelKey.String("serial") + // local_serial + DBCassandraConsistencyLevelLocalSerial = DBCassandraConsistencyLevelKey.String("local_serial") +) + +// Call-level attributes for Apache HBase +const ( + // The [HBase namespace](https://hbase.apache.org/book.html#_namespace) being + // accessed. To be used instead of the generic `db.name` attribute. + // + // Type: string + // Required: Always + // Examples: 'default' + DBHBaseNamespaceKey = attribute.Key("db.hbase.namespace") +) +// Call-level attributes for Redis +const ( + // The index of the database being accessed as used in the [`SELECT` + // command](https://redis.io/commands/select), provided as an integer. To be used + // instead of the generic `db.name` attribute. + // + // Type: int + // Required: Required, if other than the default database (`0`). + // Examples: 0, 1, 15 + DBRedisDBIndexKey = attribute.Key("db.redis.database_index") +) + +// Call-level attributes for MongoDB +const ( + // The collection being accessed within the database stated in `db.name`. + // + // Type: string + // Required: Always + // Examples: 'customers', 'products' + DBMongoDBCollectionKey = attribute.Key("db.mongodb.collection") +) + +// Call-level attrbiutes for SQL databases +const ( + // The name of the primary table that the operation is acting upon, including the + // schema name (if applicable). + // + // Type: string + // Required: Recommended if available. + // Examples: 'public.users', 'customers' + // Note: It is not recommended to attempt any client-side parsing of + // `db.statement` just to get this property, but it should be set if it is + // provided by the library being instrumented. If the operation is acting upon an + // anonymous table, or more than one table, this value MUST NOT be set. + DBSQLTableKey = attribute.Key("db.sql.table") +) + +// This document defines the attributes used to report a single exception associated with a span. +const ( + // The type of the exception (its fully-qualified class name, if applicable). The + // dynamic type of the exception should be preferred over the static type in + // languages that support it. + // + // Type: string + // Required: No + // Examples: 'java.net.ConnectException', 'OSError' + ExceptionTypeKey = attribute.Key("exception.type") + // The exception message. + // + // Type: string + // Required: No + // Examples: 'Division by zero', "Can't convert 'int' object to str implicitly" + ExceptionMessageKey = attribute.Key("exception.message") + // A stacktrace as a string in the natural representation for the language + // runtime. The representation is to be determined and documented by each language + // SIG. + // + // Type: string + // Required: No + // Examples: 'Exception in thread "main" java.lang.RuntimeException: Test + // exception\\n at ' + // 'com.example.GenerateTrace.methodB(GenerateTrace.java:13)\\n at ' + // 'com.example.GenerateTrace.methodA(GenerateTrace.java:9)\\n at ' + // 'com.example.GenerateTrace.main(GenerateTrace.java:5)' + ExceptionStacktraceKey = attribute.Key("exception.stacktrace") + // SHOULD be set to true if the exception event is recorded at a point where it is + // known that the exception is escaping the scope of the span. + // + // Type: boolean + // Required: No + // Note: An exception is considered to have escaped (or left) the scope of a span, + // if that span is ended while the exception is still logically "in flight". + // This may be actually "in flight" in some languages (e.g. if the exception + // is passed to a Context manager's `__exit__` method in Python) but will + // usually be caught at the point of recording the exception in most languages. + + // It is usually not possible to determine at the point where an exception is + // thrown + // whether it will escape the scope of a span. + // However, it is trivial to know that an exception + // will escape, if one checks for an active exception just before ending the span, + // as done in the [example above](#exception-end-example). + + // It follows that an exception may still escape the scope of the span + // even if the `exception.escaped` attribute was not set or set to false, + // since the event might have been recorded at a time where it was not + // clear whether the exception will escape. + ExceptionEscapedKey = attribute.Key("exception.escaped") +) + +// This semantic convention describes an instance of a function that runs without provisioning or managing of servers (also known as serverless functions or Function as a Service (FaaS)) with spans. +const ( + // Type of the trigger on which the function is executed. + // + // Type: Enum + // Required: On FaaS instances, faas.trigger MUST be set on incoming invocations. + // Clients invoking FaaS instances MUST set `faas.trigger` on outgoing + // invocations, if it is known to the client. This is, for example, not the case, + // when the transport layer is abstracted in a FaaS client framework without + // access to its configuration. + FaaSTriggerKey = attribute.Key("faas.trigger") + // The execution ID of the current function execution. + // + // Type: string + // Required: No + // Examples: 'af9d5aa4-a685-4c5f-a22b-444f80b3cc28' + FaaSExecutionKey = attribute.Key("faas.execution") +) + +var ( + // A response to some data source operation such as a database or filesystem read/write + FaaSTriggerDatasource = FaaSTriggerKey.String("datasource") + // To provide an answer to an inbound HTTP request + FaaSTriggerHTTP = FaaSTriggerKey.String("http") + // A function is set to be executed when messages are sent to a messaging system + FaaSTriggerPubsub = FaaSTriggerKey.String("pubsub") + // A function is scheduled to be executed regularly + FaaSTriggerTimer = FaaSTriggerKey.String("timer") + // If none of the others apply + FaaSTriggerOther = FaaSTriggerKey.String("other") +) + +// Semantic Convention for FaaS triggered as a response to some data source operation such as a database or filesystem read/write. +const ( + // The name of the source on which the triggering operation was performed. For + // example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos + // DB to the database name. + // + // Type: string + // Required: Always + // Examples: 'myBucketName', 'myDBName' + FaaSDocumentCollectionKey = attribute.Key("faas.document.collection") + // Describes the type of the operation that was performed on the data. + // + // Type: Enum + // Required: Always + FaaSDocumentOperationKey = attribute.Key("faas.document.operation") + // A string containing the time when the data was accessed in the [ISO + // 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed + // in [UTC](https://www.w3.org/TR/NOTE-datetime). + // + // Type: string + // Required: Always + // Examples: '2020-01-23T13:47:06Z' + FaaSDocumentTimeKey = attribute.Key("faas.document.time") + // The document name/table subjected to the operation. For example, in Cloud + // Storage or S3 is the name of the file, and in Cosmos DB the table name. + // + // Type: string + // Required: No + // Examples: 'myFile.txt', 'myTableName' + FaaSDocumentNameKey = attribute.Key("faas.document.name") +) + +var ( + // When a new object is created + FaaSDocumentOperationInsert = FaaSDocumentOperationKey.String("insert") + // When an object is modified + FaaSDocumentOperationEdit = FaaSDocumentOperationKey.String("edit") + // When an object is deleted + FaaSDocumentOperationDelete = FaaSDocumentOperationKey.String("delete") +) + +// Semantic Convention for FaaS scheduled to be executed regularly. +const ( + // A string containing the function invocation time in the [ISO + // 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed + // in [UTC](https://www.w3.org/TR/NOTE-datetime). + // + // Type: string + // Required: Always + // Examples: '2020-01-23T13:47:06Z' + FaaSTimeKey = attribute.Key("faas.time") + // A string containing the schedule period as [Cron Expression](https://docs.oracl + // e.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). + // + // Type: string + // Required: No + // Examples: '0/5 * * * ? *' + FaaSCronKey = attribute.Key("faas.cron") +) + +// Contains additional attributes for incoming FaaS spans. +const ( + // A boolean that is true if the serverless function is executed for the first + // time (aka cold-start). + // + // Type: boolean + // Required: No + FaaSColdstartKey = attribute.Key("faas.coldstart") +) + +// Contains additional attributes for outgoing FaaS spans. +const ( + // The name of the invoked function. + // + // Type: string + // Required: Always + // Examples: 'my-function' + // Note: SHOULD be equal to the `faas.name` resource attribute of the invoked + // function. + FaaSInvokedNameKey = attribute.Key("faas.invoked_name") + // The cloud provider of the invoked function. + // + // Type: Enum + // Required: Always + // Examples: 'aws' + // Note: SHOULD be equal to the `cloud.provider` resource attribute of the invoked + // function. + FaaSInvokedProviderKey = attribute.Key("faas.invoked_provider") + // The cloud region of the invoked function. + // + // Type: string + // Required: For some cloud providers, like AWS or GCP, the region in which a + // function is hosted is essential to uniquely identify the function and also part + // of its endpoint. Since it's part of the endpoint being called, the region is + // always known to clients. In these cases, `faas.invoked_region` MUST be set + // accordingly. If the region is unknown to the client or not required for + // identifying the invoked function, setting `faas.invoked_region` is optional. + // Examples: 'eu-central-1' + // Note: SHOULD be equal to the `cloud.region` resource attribute of the invoked + // function. + FaaSInvokedRegionKey = attribute.Key("faas.invoked_region") +) + +var ( + // Amazon Web Services + FaaSInvokedProviderAWS = FaaSInvokedProviderKey.String("aws") + // Microsoft Azure + FaaSInvokedProviderAzure = FaaSInvokedProviderKey.String("azure") + // Google Cloud Platform + FaaSInvokedProviderGCP = FaaSInvokedProviderKey.String("gcp") +) + +// These attributes may be used for any network related operation. +const ( + // Transport protocol used. See note below. + // + // Type: Enum + // Required: No + // Examples: 'ip_tcp' + NetTransportKey = attribute.Key("net.transport") + // Remote address of the peer (dotted decimal for IPv4 or + // [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) + // + // Type: string + // Required: No + // Examples: '127.0.0.1' + NetPeerIPKey = attribute.Key("net.peer.ip") // Remote port number. + // + // Type: int + // Required: No + // Examples: 80, 8080, 443 NetPeerPortKey = attribute.Key("net.peer.port") - - // Remote hostname or similar. + // Remote hostname or similar, see note below. + // + // Type: string + // Required: No + // Examples: 'example.com' NetPeerNameKey = attribute.Key("net.peer.name") - - // Local host IP. Useful in case of a multi-IP host. + // Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. + // + // Type: string + // Required: No + // Examples: '192.168.0.1' NetHostIPKey = attribute.Key("net.host.ip") - - // Local host port. + // Like `net.peer.port` but for the host port. + // + // Type: int + // Required: No + // Examples: 35555 NetHostPortKey = attribute.Key("net.host.port") - - // Local hostname or similar. + // Local hostname or similar, see note below. + // + // Type: string + // Required: No + // Examples: 'localhost' NetHostNameKey = attribute.Key("net.host.name") ) -// Semantic conventions for common transport protocol attributes. var ( - NetTransportTCP = NetTransportKey.String("IP.TCP") - NetTransportUDP = NetTransportKey.String("IP.UDP") - NetTransportIP = NetTransportKey.String("IP") - NetTransportUnix = NetTransportKey.String("Unix") - NetTransportPipe = NetTransportKey.String("pipe") + // ip_tcp + NetTransportTCP = NetTransportKey.String("ip_tcp") + // ip_udp + NetTransportUDP = NetTransportKey.String("ip_udp") + // Another IP-based protocol + NetTransportIP = NetTransportKey.String("ip") + // Unix Domain socket. See below + NetTransportUnix = NetTransportKey.String("unix") + // Named or anonymous pipe. See note below + NetTransportPipe = NetTransportKey.String("pipe") + // In-process communication NetTransportInProc = NetTransportKey.String("inproc") - NetTransportOther = NetTransportKey.String("other") + // Something else (non IP-based) + NetTransportOther = NetTransportKey.String("other") ) -// General attribute keys for spans. +// Operations that access some remote service. const ( - // Service name of the remote service. Should equal the actual - // `service.name` resource attribute of the remote service, if any. + // The [`service.name`](../../resource/semantic_conventions/README.md#service) of + // the remote service. SHOULD be equal to the actual `service.name` resource + // attribute of the remote service if any. + // + // Type: string + // Required: No + // Examples: 'AuthTokenCache' PeerServiceKey = attribute.Key("peer.service") ) -// Semantic conventions for attribute keys used to identify an authorized -// user. +// These attributes may be used for any operation with an authenticated and/or authorized enduser. const ( - // Username or the client identifier extracted from the access token or - // authorization header in the inbound request from outside the system. + // Username or client_id extracted from the access token or + // [Authorization](https://tools.ietf.org/html/rfc7235#section-4.2) header in the + // inbound request from outside the system. + // + // Type: string + // Required: No + // Examples: 'username' EnduserIDKey = attribute.Key("enduser.id") - - // Actual or assumed role the client is making the request with. + // Actual/assumed role the client is making the request under extracted from token + // or application security context. + // + // Type: string + // Required: No + // Examples: 'admin' EnduserRoleKey = attribute.Key("enduser.role") - - // Scopes or granted authorities the client currently possesses. + // Scopes or granted authorities the client currently possesses extracted from + // token or application security context. The value would come from the scope + // associated with an [OAuth 2.0 Access + // Token](https://tools.ietf.org/html/rfc6749#section-3.3) or an attribute value + // in a [SAML 2.0 Assertion](http://docs.oasis- + // open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html). + // + // Type: string + // Required: No + // Examples: 'read:message, write:files' EnduserScopeKey = attribute.Key("enduser.scope") ) -// Semantic conventions for attribute keys for HTTP. +// These attributes may be used for any operation to store information about a thread that started a span. +const ( + // Current "managed" thread ID (as opposed to OS thread ID). + // + // Type: int + // Required: No + // Examples: 42 + ThreadIDKey = attribute.Key("thread.id") + // Current thread name. + // + // Type: string + // Required: No + // Examples: 'main' + ThreadNameKey = attribute.Key("thread.name") +) + +// These attributes allow to report this unit of code and therefore to provide more context about the span. +const ( + // The method or function name, or equivalent (usually rightmost part of the code + // unit's name). + // + // Type: string + // Required: No + // Examples: 'serveRequest' + CodeFunctionKey = attribute.Key("code.function") + // The "namespace" within which `code.function` is defined. Usually the qualified + // class or module name, such that `code.namespace` + some separator + + // `code.function` form a unique identifier for the code unit. + // + // Type: string + // Required: No + // Examples: 'com.example.MyHTTPService' + CodeNamespaceKey = attribute.Key("code.namespace") + // The source code file name that identifies the code unit as uniquely as possible + // (preferably an absolute file path). + // + // Type: string + // Required: No + // Examples: '/usr/local/MyApplication/content_root/app/index.php' + CodeFilepathKey = attribute.Key("code.filepath") + // The line number in `code.filepath` best representing the operation. It SHOULD + // point within the code unit named in `code.function`. + // + // Type: int + // Required: No + // Examples: 42 + CodeLineNumberKey = attribute.Key("code.lineno") +) + +// This document defines semantic conventions for HTTP client and server Spans. const ( // HTTP request method. + // + // Type: string + // Required: Always + // Examples: 'GET', 'POST', 'HEAD' HTTPMethodKey = attribute.Key("http.method") - - // Full HTTP request URL in the form: - // scheme://host[:port]/path?query[#fragment]. + // Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. + // Usually the fragment is not transmitted over HTTP, but if it is known, it + // should be included nevertheless. + // + // Type: string + // Required: No + // Examples: 'https://www.foo.bar/search?q=OpenTelemetry#SemConv' + // Note: `http.url` MUST NOT contain credentials passed via URL in form of + // `https://username:password@www.example.com/`. In such case the attribute's + // value should be `https://www.example.com/`. HTTPURLKey = attribute.Key("http.url") - - // The full request target as passed in a HTTP request line or - // equivalent, e.g. "/path/12314/?q=ddds#123". + // The full request target as passed in a HTTP request line or equivalent. + // + // Type: string + // Required: No + // Examples: '/path/12314/?q=ddds#123' HTTPTargetKey = attribute.Key("http.target") - - // The value of the HTTP host header. + // The value of the [HTTP host + // header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is + // empty or not present, this attribute should be the same. + // + // Type: string + // Required: No + // Examples: 'www.example.org' HTTPHostKey = attribute.Key("http.host") - // The URI scheme identifying the used protocol. + // + // Type: string + // Required: No + // Examples: 'http', 'https' HTTPSchemeKey = attribute.Key("http.scheme") - - // HTTP response status code. + // [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). + // + // Type: int + // Required: If and only if one was received/sent. + // Examples: 200 HTTPStatusCodeKey = attribute.Key("http.status_code") - // Kind of HTTP protocol used. + // + // Type: Enum + // Required: No + // Examples: '1.0' + // Note: If `net.transport` is not specified, it can be assumed to be `IP.TCP` + // except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. HTTPFlavorKey = attribute.Key("http.flavor") - - // Value of the HTTP User-Agent header sent by the client. + // Value of the [HTTP User- + // Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the + // client. + // + // Type: string + // Required: No + // Examples: 'CERN-LineMode/2.15 libwww/2.17b3' HTTPUserAgentKey = attribute.Key("http.user_agent") - - // The primary server name of the matched virtual host. - HTTPServerNameKey = attribute.Key("http.server_name") - - // The matched route served (path template). For example, - // "/users/:userID?". - HTTPRouteKey = attribute.Key("http.route") - - // The IP address of the original client behind all proxies, if known - // (e.g. from X-Forwarded-For). - HTTPClientIPKey = attribute.Key("http.client_ip") - - // The size of the request payload body in bytes. + // The size of the request payload body in bytes. This is the number of bytes + // transferred excluding headers and is often, but not always, present as the + // [Content-Length](https://tools.ietf.org/html/rfc7230#section-3.3.2) header. For + // requests using transport encoding, this should be the compressed size. + // + // Type: int + // Required: No + // Examples: 3495 HTTPRequestContentLengthKey = attribute.Key("http.request_content_length") - - // The size of the uncompressed request payload body after transport decoding. - // Not set if transport encoding not used. + // The size of the uncompressed request payload body after transport decoding. Not + // set if transport encoding not used. + // + // Type: int + // Required: No + // Examples: 5493 HTTPRequestContentLengthUncompressedKey = attribute.Key("http.request_content_length_uncompressed") - - // The size of the response payload body in bytes. + // The size of the response payload body in bytes. This is the number of bytes + // transferred excluding headers and is often, but not always, present as the + // [Content-Length](https://tools.ietf.org/html/rfc7230#section-3.3.2) header. For + // requests using transport encoding, this should be the compressed size. + // + // Type: int + // Required: No + // Examples: 3495 HTTPResponseContentLengthKey = attribute.Key("http.response_content_length") - // The size of the uncompressed response payload body after transport decoding. // Not set if transport encoding not used. + // + // Type: int + // Required: No + // Examples: 5493 HTTPResponseContentLengthUncompressedKey = attribute.Key("http.response_content_length_uncompressed") ) -// Semantic conventions for common HTTP 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") + // HTTP 1.0 + HTTPFlavorHTTP10 = HTTPFlavorKey.String("1.0") + // HTTP 1.1 + HTTPFlavorHTTP11 = HTTPFlavorKey.String("1.1") + // HTTP 2 + HTTPFlavorHTTP20 = HTTPFlavorKey.String("2.0") + // SPDY protocol HTTPFlavorSPDY = HTTPFlavorKey.String("SPDY") + // QUIC protocol HTTPFlavorQUIC = HTTPFlavorKey.String("QUIC") ) -// Semantic conventions for attribute keys for database connections. +// Semantic Convention for HTTP Server const ( - // Identifier for the database system (DBMS) being used. - DBSystemKey = attribute.Key("db.system") - - // Database Connection String with embedded credentials removed. - DBConnectionStringKey = attribute.Key("db.connection_string") - - // Username for accessing database. - DBUserKey = attribute.Key("db.user") + // The primary server name of the matched virtual host. This should be obtained + // via configuration. If no such configuration can be obtained, this attribute + // MUST NOT be set ( `net.host.name` should be used instead). + // + // Type: string + // Required: No + // Examples: 'example.com' + // Note: `http.url` is usually not readily available on the server side but would + // have to be assembled in a cumbersome and sometimes lossy process from other + // information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus + // preferred to supply the raw data that is available. + HTTPServerNameKey = attribute.Key("http.server_name") + // The matched route (path template). + // + // Type: string + // Required: No + // Examples: '/users/:userID?' + HTTPRouteKey = attribute.Key("http.route") + // The IP address of the original client behind all proxies, if known (e.g. from + // [X-Forwarded-For](https://developer.mozilla.org/en- + // US/docs/Web/HTTP/Headers/X-Forwarded-For)). + // + // Type: string + // Required: No + // Examples: '83.164.160.102' + // Note: This is not necessarily the same as `net.peer.ip`, which would identify + // the network-level peer, which may be a proxy. + HTTPClientIPKey = attribute.Key("http.client_ip") ) -// Semantic conventions for common database system 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 attribute keys for database calls. -const ( - // Database instance name. - DBNameKey = attribute.Key("db.name") - - // A database statement for the given database type. - DBStatementKey = attribute.Key("db.statement") - - // A database operation for the given database type. - DBOperationKey = attribute.Key("db.operation") +// Attributes that exist for multiple DynamoDB request types. +const ( + // The keys in the `RequestItems` object field. + // + // Type: string[] + // Required: No + // Examples: 'Users', 'Cats' + AWSDynamoDBTableNamesKey = attribute.Key("aws.dynamodb.table_names") + // The JSON-serialized value of each item in the `ConsumedCapacity` response + // field. + // + // Type: string[] + // Required: No + // Examples: '{ "CapacityUnits": number, "GlobalSecondaryIndexes": { "string" : { + // "CapacityUnits": number, "ReadCapacityUnits": number, "WriteCapacityUnits": + // number } }, "LocalSecondaryIndexes": { "string" : { "CapacityUnits": number, + // "ReadCapacityUnits": number, "WriteCapacityUnits": number } }, + // "ReadCapacityUnits": number, "Table": { "CapacityUnits": number, + // "ReadCapacityUnits": number, "WriteCapacityUnits": number }, "TableName": + // "string", "WriteCapacityUnits": number }' + AWSDynamoDBConsumedCapacityKey = attribute.Key("aws.dynamodb.consumed_capacity") + // The JSON-serialized value of the `ItemCollectionMetrics` response field. + // + // Type: string + // Required: No + // Examples: '{ "string" : [ { "ItemCollectionKey": { "string" : { "B": blob, + // "BOOL": boolean, "BS": [ blob ], "L": [ "AttributeValue" ], "M": { "string" : + // "AttributeValue" }, "N": "string", "NS": [ "string" ], "NULL": boolean, "S": + // "string", "SS": [ "string" ] } }, "SizeEstimateRangeGB": [ number ] } ] }' + AWSDynamoDBItemCollectionMetricsKey = attribute.Key("aws.dynamodb.item_collection_metrics") + // The value of the `ProvisionedThroughput.ReadCapacityUnits` request parameter. + // + // Type: double + // Required: No + // Examples: 1.0, 2.0 + AWSDynamoDBProvisionedReadCapacityKey = attribute.Key("aws.dynamodb.provisioned_read_capacity") + // The value of the `ProvisionedThroughput.WriteCapacityUnits` request parameter. + // + // Type: double + // Required: No + // Examples: 1.0, 2.0 + AWSDynamoDBProvisionedWriteCapacityKey = attribute.Key("aws.dynamodb.provisioned_write_capacity") + // The value of the `ConsistentRead` request parameter. + // + // Type: boolean + // Required: No + AWSDynamoDBConsistentReadKey = attribute.Key("aws.dynamodb.consistent_read") + // The value of the `ProjectionExpression` request parameter. + // + // Type: string + // Required: No + // Examples: 'Title', 'Title, Price, Color', 'Title, Description, RelatedItems, + // ProductReviews' + AWSDynamoDBProjectionKey = attribute.Key("aws.dynamodb.projection") + // The value of the `Limit` request parameter. + // + // Type: int + // Required: No + // Examples: 10 + AWSDynamoDBLimitKey = attribute.Key("aws.dynamodb.limit") + // The value of the `AttributesToGet` request parameter. + // + // Type: string[] + // Required: No + // Examples: 'lives', 'id' + AWSDynamoDBAttributesToGetKey = attribute.Key("aws.dynamodb.attributes_to_get") + // The value of the `IndexName` request parameter. + // + // Type: string + // Required: No + // Examples: 'name_to_group' + AWSDynamoDBIndexNameKey = attribute.Key("aws.dynamodb.index_name") + // The value of the `Select` request parameter. + // + // Type: string + // Required: No + // Examples: 'ALL_ATTRIBUTES', 'COUNT' + AWSDynamoDBSelectKey = attribute.Key("aws.dynamodb.select") ) -// Database technology-specific attributes +// DynamoDB.CreateTable const ( - // Name of the Cassandra keyspace accessed. Use instead of `db.name`. - DBCassandraKeyspaceKey = attribute.Key("db.cassandra.keyspace") - - // HBase namespace accessed. Use instead of `db.name`. - DBHBaseNamespaceKey = attribute.Key("db.hbase.namespace") - - // Index of Redis database accessed. Use instead of `db.name`. - DBRedisDBIndexKey = attribute.Key("db.redis.database_index") - - // Collection being accessed within the database in `db.name`. - DBMongoDBCollectionKey = attribute.Key("db.mongodb.collection") + // The JSON-serialized value of each item of the `GlobalSecondaryIndexes` request + // field + // + // Type: string[] + // Required: No + // Examples: '{ "IndexName": "string", "KeySchema": [ { "AttributeName": "string", + // "KeyType": "string" } ], "Projection": { "NonKeyAttributes": [ "string" ], + // "ProjectionType": "string" }, "ProvisionedThroughput": { "ReadCapacityUnits": + // number, "WriteCapacityUnits": number } }' + AWSDynamoDBGlobalSecondaryIndexesKey = attribute.Key("aws.dynamodb.global_secondary_indexes") + // The JSON-serialized value of each item of the `LocalSecondaryIndexes` request + // field. + // + // Type: string[] + // Required: No + // Examples: '{ "IndexArn": "string", "IndexName": "string", "IndexSizeBytes": + // number, "ItemCount": number, "KeySchema": [ { "AttributeName": "string", + // "KeyType": "string" } ], "Projection": { "NonKeyAttributes": [ "string" ], + // "ProjectionType": "string" } }' + AWSDynamoDBLocalSecondaryIndexesKey = attribute.Key("aws.dynamodb.local_secondary_indexes") ) -// Semantic conventions for attribute keys for RPC. +// DynamoDB.ListTables const ( - // A string identifying the remoting system. - RPCSystemKey = attribute.Key("rpc.system") - - // The full name of the service being called. - RPCServiceKey = attribute.Key("rpc.service") - - // The name of the method being called. - RPCMethodKey = attribute.Key("rpc.method") - - // Name of message transmitted or received. - RPCNameKey = attribute.Key("name") - - // Type of message transmitted or received. - RPCMessageTypeKey = attribute.Key("message.type") - - // Identifier of message transmitted or received. - RPCMessageIDKey = attribute.Key("message.id") - - // The compressed size of the message transmitted or received in bytes. - RPCMessageCompressedSizeKey = attribute.Key("message.compressed_size") - - // The uncompressed size of the message transmitted or received in - // bytes. - RPCMessageUncompressedSizeKey = attribute.Key("message.uncompressed_size") + // The value of the `ExclusiveStartTableName` request parameter. + // + // Type: string + // Required: No + // Examples: 'Users', 'CatsTable' + AWSDynamoDBExclusiveStartTableKey = attribute.Key("aws.dynamodb.exclusive_start_table") + // The the number of items in the `TableNames` response parameter. + // + // Type: int + // Required: No + // Examples: 20 + AWSDynamoDBTableCountKey = attribute.Key("aws.dynamodb.table_count") ) -// Semantic conventions for common RPC attributes. -var ( - // Semantic convention for gRPC as the remoting system. - RPCSystemGRPC = RPCSystemKey.String("grpc") +// DynamoDB.Query +const ( + // The value of the `ScanIndexForward` request parameter. + // + // Type: boolean + // Required: No + AWSDynamoDBScanForwardKey = attribute.Key("aws.dynamodb.scan_forward") +) - // Semantic convention for a message named message. - RPCNameMessage = RPCNameKey.String("message") +// DynamoDB.Scan +const ( + // The value of the `Segment` request parameter. + // + // Type: int + // Required: No + // Examples: 10 + AWSDynamoDBSegmentKey = attribute.Key("aws.dynamodb.segment") + // The value of the `TotalSegments` request parameter. + // + // Type: int + // Required: No + // Examples: 100 + AWSDynamoDBTotalSegmentsKey = attribute.Key("aws.dynamodb.total_segments") + // The value of the `Count` response parameter. + // + // Type: int + // Required: No + // Examples: 10 + AWSDynamoDBCountKey = attribute.Key("aws.dynamodb.count") + // The value of the `ScannedCount` response parameter. + // + // Type: int + // Required: No + // Examples: 50 + AWSDynamoDBScannedCountKey = attribute.Key("aws.dynamodb.scanned_count") +) - // Semantic conventions for RPC message types. - RPCMessageTypeSent = RPCMessageTypeKey.String("SENT") - RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED") +// DynamoDB.UpdateTable +const ( + // The JSON-serialized value of each item in the `AttributeDefinitions` request + // field. + // + // Type: string[] + // Required: No + // Examples: '{ "AttributeName": "string", "AttributeType": "string" }' + AWSDynamoDBAttributeDefinitionsKey = attribute.Key("aws.dynamodb.attribute_definitions") + // The JSON-serialized value of each item in the the `GlobalSecondaryIndexUpdates` + // request field. + // + // Type: string[] + // Required: No + // Examples: '{ "Create": { "IndexName": "string", "KeySchema": [ { + // "AttributeName": "string", "KeyType": "string" } ], "Projection": { + // "NonKeyAttributes": [ "string" ], "ProjectionType": "string" }, + // "ProvisionedThroughput": { "ReadCapacityUnits": number, "WriteCapacityUnits": + // number } }' + AWSDynamoDBGlobalSecondaryIndexUpdatesKey = attribute.Key("aws.dynamodb.global_secondary_index_updates") ) -// Semantic conventions for attribute keys for messaging systems. +// This document defines the attributes used in messaging systems. const ( - // A unique identifier describing the messaging system. For example, - // kafka, rabbitmq or activemq. + // A string identifying the messaging system. + // + // Type: string + // Required: Always + // Examples: 'kafka', 'rabbitmq', 'activemq', 'AmazonSQS' MessagingSystemKey = attribute.Key("messaging.system") - - // The message destination name, e.g. MyQueue or MyTopic. + // The message destination name. This might be equal to the span name but is + // required nevertheless. + // + // Type: string + // Required: Always + // Examples: 'MyQueue', 'MyTopic' MessagingDestinationKey = attribute.Key("messaging.destination") - - // The kind of message destination. + // The kind of message destination + // + // Type: Enum + // Required: Required only if the message destination is either a `queue` or + // `topic`. MessagingDestinationKindKey = attribute.Key("messaging.destination_kind") - - // Describes if the destination is temporary or not. + // A boolean that is true if the message destination is temporary. + // + // Type: boolean + // Required: If missing, it is assumed to be false. MessagingTempDestinationKey = attribute.Key("messaging.temp_destination") - // The name of the transport protocol. + // + // Type: string + // Required: No + // Examples: 'AMQP', 'MQTT' MessagingProtocolKey = attribute.Key("messaging.protocol") - // The version of the transport protocol. + // + // Type: string + // Required: No + // Examples: '0.9.1' MessagingProtocolVersionKey = attribute.Key("messaging.protocol_version") - - // Messaging service URL. + // Connection string. + // + // Type: string + // Required: No + // Examples: 'tibjmsnaming://localhost:7222', + // 'https://queue.amazonaws.com/80398EXAMPLE/MyQueue' MessagingURLKey = attribute.Key("messaging.url") - - // Identifier used by the messaging system for a message. + // A value used by the messaging system as an identifier for the message, + // represented as a string. + // + // Type: string + // Required: No + // Examples: '452a7c7c7c7048c2f887f61572b18fc2' MessagingMessageIDKey = attribute.Key("messaging.message_id") - - // Identifier used by the messaging system for a conversation. + // The [conversation ID](#conversations) identifying the conversation to which the + // message belongs, represented as a string. Sometimes called "Correlation ID". + // + // Type: string + // Required: No + // Examples: 'MyConversationId' MessagingConversationIDKey = attribute.Key("messaging.conversation_id") - - // The (uncompressed) size of the message payload in bytes. + // The (uncompressed) size of the message payload in bytes. Also use this + // attribute if it is unknown whether the compressed or uncompressed payload size + // is reported. + // + // Type: int + // Required: No + // Examples: 2738 MessagingMessagePayloadSizeBytesKey = attribute.Key("messaging.message_payload_size_bytes") - // The compressed size of the message payload in bytes. + // + // Type: int + // Required: No + // Examples: 2048 MessagingMessagePayloadCompressedSizeBytesKey = attribute.Key("messaging.message_payload_compressed_size_bytes") - - // Identifies which part and kind of message consumption is being - // preformed. - MessagingOperationKey = attribute.Key("messaging.operation") - - // RabbitMQ specific attribute describing the destination routing key. - MessagingRabbitMQRoutingKeyKey = attribute.Key("messaging.rabbitmq.routing_key") ) -// Semantic conventions for common messaging system attributes. var ( - // Semantic conventions for message destinations. - MessagingDestinationKindKeyQueue = MessagingDestinationKindKey.String("queue") - MessagingDestinationKindKeyTopic = MessagingDestinationKindKey.String("topic") + // A message sent to a queue + MessagingDestinationKindQueue = MessagingDestinationKindKey.String("queue") + // A message sent to a topic + MessagingDestinationKindTopic = MessagingDestinationKindKey.String("topic") +) - // Semantic convention for message destinations that are temporary. - MessagingTempDestination = MessagingTempDestinationKey.Bool(true) +// Semantic convention for a consumer of messages received from a messaging system +const ( + // A string identifying the kind of message consumption as defined in the + // [Operation names](#operation-names) section above. If the operation is "send", + // this attribute MUST NOT be set, since the operation can be inferred from the + // span kind in that case. + // + // Type: Enum + // Required: No + MessagingOperationKey = attribute.Key("messaging.operation") +) - // 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. +var ( + // receive MessagingOperationReceive = MessagingOperationKey.String("receive") + // process MessagingOperationProcess = MessagingOperationKey.String("process") ) -// Semantic conventions for attribute keys for FaaS systems. +// Attributes for RabbitMQ const ( - - // Type of the trigger on which the function is executed. - FaaSTriggerKey = attribute.Key("faas.trigger") - - // String containing the execution identifier of the function. - FaaSExecutionKey = attribute.Key("faas.execution") - - // A boolean indicating that the serverless function is executed - // for the first time (aka cold start). - FaaSColdstartKey = attribute.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 = attribute.Key("faas.document.collection") - - // The type of the operation that was performed on the data. - FaaSDocumentOperationKey = attribute.Key("faas.document.operation") - - // A string containing the time when the data was accessed. - FaaSDocumentTimeKey = attribute.Key("faas.document.time") - - // The document name/table subjected to the operation. - FaaSDocumentNameKey = attribute.Key("faas.document.name") - - // The function invocation time. - FaaSTimeKey = attribute.Key("faas.time") - - // The schedule period as Cron Expression. - FaaSCronKey = attribute.Key("faas.cron") + // RabbitMQ message routing key. + // + // Type: string + // Required: Unless it is empty. + // Examples: 'myKey' + MessagingRabbitmqRoutingKeyKey = attribute.Key("messaging.rabbitmq.routing_key") ) -// Semantic conventions for common FaaS 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") +// Attributes for Apache Kafka +const ( + // Message keys in Kafka are used for grouping alike messages to ensure they're + // processed on the same partition. They differ from `messaging.message_id` in + // that they're not unique. If the key is `null`, the attribute MUST NOT be set. + // + // Type: string + // Required: No + // Examples: 'myKey' + // Note: If the key type is not string, it's string representation has to be + // supplied for the attribute. If the key has no unambiguous, canonical string + // form, don't include its value. + MessagingKafkaMessageKeyKey = attribute.Key("messaging.kafka.message_key") + // Name of the Kafka Consumer Group that is handling the message. Only applies to + // consumers, not producers. + // + // Type: string + // Required: No + // Examples: 'my-group' + MessagingKafkaConsumerGroupKey = attribute.Key("messaging.kafka.consumer_group") + // Client ID for the Consumer or Producer that is handling the message. + // + // Type: string + // Required: No + // Examples: 'client-5' + MessagingKafkaClientIDKey = attribute.Key("messaging.kafka.client_id") + // Partition the message is sent to. + // + // Type: int + // Required: No + // Examples: 2 + MessagingKafkaPartitionKey = attribute.Key("messaging.kafka.partition") + // A boolean that is true if the message is a tombstone. + // + // Type: boolean + // Required: If missing, it is assumed to be false. + MessagingKafkaTombstoneKey = attribute.Key("messaging.kafka.tombstone") ) -// Semantic conventions for source code attributes. +// This document defines semantic conventions for remote procedure calls. const ( - // The method or function name, or equivalent (usually rightmost part of - // the code unit's name). - CodeFunctionKey = attribute.Key("code.function") - - // The "namespace" within which `code.function` is defined. Usually the - // qualified class or module name, such that - // `code.namespace` + some separator + `code.function` form a unique - // identifier for the code unit. - CodeNamespaceKey = attribute.Key("code.namespace") + // A string identifying the remoting system. + // + // Type: string + // Required: Always + // Examples: 'grpc', 'java_rmi', 'wcf' + RPCSystemKey = attribute.Key("rpc.system") + // The full name of the service being called, including its package name, if + // applicable. + // + // Type: string + // Required: No, but recommended + // Examples: 'myservice.EchoService' + RPCServiceKey = attribute.Key("rpc.service") + // The name of the method being called, must be equal to the $method part in the + // span name. + // + // Type: string + // Required: No, but recommended + // Examples: 'exampleMethod' + RPCMethodKey = attribute.Key("rpc.method") +) - // The source code file name that identifies the code unit as uniquely as - // possible (preferably an absolute file path). - CodeFilepathKey = attribute.Key("code.filepath") +// Tech-specific attributes for gRPC. +const ( + // The [numeric status + // code](https://github.com/grpc/grpc/blob/v1.33.2/doc/statuscodes.md) of the gRPC + // request. + // + // Type: Enum + // Required: Always + // Examples: 0, 1, 16 + RPCGRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code") +) - // The line number in `code.filepath` best representing the operation. - // It SHOULD point within the code unit named in `code.function`. - CodeLineNumberKey = attribute.Key("code.lineno") +var ( + // OK + RPCGRPCStatusCodeOk = RPCGRPCStatusCodeKey.Int(0) + // CANCELLED + RPCGRPCStatusCodeCancelled = RPCGRPCStatusCodeKey.Int(1) + // UNKNOWN + RPCGRPCStatusCodeUnknown = RPCGRPCStatusCodeKey.Int(2) + // INVALID_ARGUMENT + RPCGRPCStatusCodeInvalidArgument = RPCGRPCStatusCodeKey.Int(3) + // DEADLINE_EXCEEDED + RPCGRPCStatusCodeDeadlineExceeded = RPCGRPCStatusCodeKey.Int(4) + // NOT_FOUND + RPCGRPCStatusCodeNotFound = RPCGRPCStatusCodeKey.Int(5) + // ALREADY_EXISTS + RPCGRPCStatusCodeAlreadyExists = RPCGRPCStatusCodeKey.Int(6) + // PERMISSION_DENIED + RPCGRPCStatusCodePermissionDenied = RPCGRPCStatusCodeKey.Int(7) + // RESOURCE_EXHAUSTED + RPCGRPCStatusCodeResourceExhausted = RPCGRPCStatusCodeKey.Int(8) + // FAILED_PRECONDITION + RPCGRPCStatusCodeFailedPrecondition = RPCGRPCStatusCodeKey.Int(9) + // ABORTED + RPCGRPCStatusCodeAborted = RPCGRPCStatusCodeKey.Int(10) + // OUT_OF_RANGE + RPCGRPCStatusCodeOutOfRange = RPCGRPCStatusCodeKey.Int(11) + // UNIMPLEMENTED + RPCGRPCStatusCodeUnimplemented = RPCGRPCStatusCodeKey.Int(12) + // INTERNAL + RPCGRPCStatusCodeInternal = RPCGRPCStatusCodeKey.Int(13) + // UNAVAILABLE + RPCGRPCStatusCodeUnavailable = RPCGRPCStatusCodeKey.Int(14) + // DATA_LOSS + RPCGRPCStatusCodeDataLoss = RPCGRPCStatusCodeKey.Int(15) + // UNAUTHENTICATED + RPCGRPCStatusCodeUnauthenticated = RPCGRPCStatusCodeKey.Int(16) )