diff --git a/.github/repository-settings.md b/.github/repository-settings.md new file mode 100644 index 0000000000..fa86d02cfc --- /dev/null +++ b/.github/repository-settings.md @@ -0,0 +1,38 @@ +# Process + +This file documents local admin changes for opentelemetry-cpp, +per the community process: https://github.com/open-telemetry/community/blob/main/docs/how-to-configure-new-repository.md + +Please note that the EasyCLA check **MUST** stay **REQUIRED**, +it should never be disabled or bypassed, at the risk of tainting the repository. + +# Guidelines + +The best is to open a PR first that describes the change, +so it can be discussed during review (maybe it is not needed, +maybe there is an alternate solution, ...). + +The PR must add a log entry in this file, detailing: + +* the date the change is implemented +* what is changed exactly (which setting) +* a short rationale + +Admin changes are then applied only when the PR is merged. + +If for some reason a change is implemented in emergency, +before a PR can be discussed and merged, +a PR should still be prepared and pushed after the fact to +describe the settings changed. + +# Log of local changes + +## 2023-11-03 + +Created log file `.github/repository-settings.md`, since admin permissions are now granted to maintainers. + +See https://github.com/open-telemetry/community/issues/1727 + +No setting changed. + + diff --git a/.github/workflows/project_management_comment.yml b/.github/workflows/project_management_comment.yml index c3ddd0034f..feba7112af 100644 --- a/.github/workflows/project_management_comment.yml +++ b/.github/workflows/project_management_comment.yml @@ -12,7 +12,7 @@ jobs: issues: write steps: - name: Add comment - uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa + uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 with: issue-number: ${{ github.event.issue.number }} body: | diff --git a/CHANGELOG.md b/CHANGELOG.md index f889a287f7..9acee42235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,23 +15,134 @@ Increment the: ## [Unreleased] +* [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead + [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) +* [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream + [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) +* [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() + [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) +* [BUILD] enum CanonicalCode names too generic... conflict with old C defines + [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) +* [API] Add a new AddLink() operation to Span + [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) + +Important changes: + +* [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() + [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) + * TracerProvider::GetTracer() now accepts InstrumentationScope attributes. + * Because this is an `ABI` breaking change, the fix is only available + with the `CMake` option `WITH_ABI_VERSION_2=ON`. + * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) + the `ABI` is unchanged, and the fix is not available. + +* [API] Add a new AddLink() operation to Span + [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) + * New `API` Span::AddLink() adds a single link to a span. + * New `API` Span::AddLinks() adds multiple links to a span. + * Because this is an `ABI` breaking change, the fix is only available + with the `CMake` option `WITH_ABI_VERSION_2=ON`. + * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) + the `ABI` is unchanged, and the fix is not available. + +* [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream + [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) + * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_PREVIEW` + is now promoted to stable. The default is changed to `ON`. + * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_TLS_PREVIEW` + is now promoted to stable. The default is changed to `ON`. + * These build options are scheduled to be removed by the next release, + building without SSL/TLS will no longer be possible. + +Breaking changes: + +* [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead + [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) + * The experimental `CMake` option `WITH_REMOVE_METER_PREVIEW` is removed, + use option `WITH_ABI_VERSION_2` instead. + +* [BUILD] enum CanonicalCode names too generic... conflict with old C defines + [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) + * Header file `opentelemetry/trace/canonical_code.h` is unused, + and is now removed. + * This header should not be included directly in an application. + If this is the case, please remove any remaining include directives. + +* [BUILD] Fix exported definitions when building DLL with STL + [#2387](https://github.com/open-telemetry/opentelemetry-cpp/pull/2387) + * The MeterSelector, MeterSelectorFactory, InstrumentSelector, + and InstrumentSelectorFactory APIs now use const std::string& + instead of nostd::string_view for name, version and schema to + maintain a single export definition for DLL. + +## [1.12.0] 2023-10-16 + +* [BUILD] Support `pkg-config` + [#2269](https://github.com/open-telemetry/opentelemetry-cpp/pull/2269) +* [CI] Do not automatically close stale issues + [#2277](https://github.com/open-telemetry/opentelemetry-cpp/pull/2277) +* [CI] Benchmark workflow fails, C++14 required to build grpc + [#2278](https://github.com/open-telemetry/opentelemetry-cpp/pull/2278) +* [SDK] Increase metric name maximum length from 63 to 255 characters + [#2284](https://github.com/open-telemetry/opentelemetry-cpp/pull/2284) +* [SEMANTIC CONVENTION] Deprecated semconv (in the spec) + not deprecated (in C++) + [#2285](https://github.com/open-telemetry/opentelemetry-cpp/pull/2285) +* [SDK] Remove unused member variables from SyncMetricStorage + [#2294](https://github.com/open-telemetry/opentelemetry-cpp/pull/2294) * [DEPRECATION] Deprecate ZPAGES [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) -* [EXPORTER] Prometheus exporter emit resource attributes - [#2301](https://github.com/open-telemetry/opentelemetry-cpp/pull/2301) -* [EXPORTER] Remove explicit timestamps from metric points exported by Prometheus +* [API] Deliver ABI breaking changes + [#2222](https://github.com/open-telemetry/opentelemetry-cpp/pull/2222) +* [SDK] Allow metric instrument names to contain / characters + [#2310](https://github.com/open-telemetry/opentelemetry-cpp/pull/2310) +* [SDK] Fix Observable Counters/UpDownCounters + [#2298](https://github.com/open-telemetry/opentelemetry-cpp/pull/2298) +* [SDK] Add exemplar reservoir to async metric storage + [#2319](https://github.com/open-telemetry/opentelemetry-cpp/pull/2319) +* [TEST] Fix lifetime issues in prometheus test utils + [#2322](https://github.com/open-telemetry/opentelemetry-cpp/pull/2322) +* [EXPORTER] Prometheus: Remove explicit timestamps from metric points [#2324](https://github.com/open-telemetry/opentelemetry-cpp/pull/2324) -* [EXPORTER] Handle attribute key collisions caused by sanitation +* [EXPORTER] Prometheus: Handle attribute key collisions from sanitation [#2326](https://github.com/open-telemetry/opentelemetry-cpp/pull/2326) -* [EXPORTER] Replace colons with underscores when converting to Prometheus label +* [EXPORTER] Prometheus cleanup, test with TranslateToPrometheus + [#2329](https://github.com/open-telemetry/opentelemetry-cpp/pull/2329) +* [SDK] Fix log message in Meter::RegisterSyncMetricStorage + [#2325](https://github.com/open-telemetry/opentelemetry-cpp/pull/2325) +* [DOC] Simplify the project status section + [#2332](https://github.com/open-telemetry/opentelemetry-cpp/pull/2332) +* [EXPORTER] Prometheus: Sanitize labels according to spec [#2330](https://github.com/open-telemetry/opentelemetry-cpp/pull/2330) +* [SDK] Fix deadlock when shuting down http client + [#2337](https://github.com/open-telemetry/opentelemetry-cpp/pull/2337) +* [Exporter] Group spans by resource and instrumentation scope + in OTLP export requests + [#2335](https://github.com/open-telemetry/opentelemetry-cpp/pull/2335) +* [BUILD] Need fine-grained HAVE_CPP_STDLIB + [#2304](https://github.com/open-telemetry/opentelemetry-cpp/pull/2304) * [API] Add InstrumentationScope attributes in MeterProvider::GetMeter() [#2224](https://github.com/open-telemetry/opentelemetry-cpp/pull/2224) * [REMOVAL] Drop C++11 support [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) -* [EXPORTER] Add otel_scope_name and otel_scope_version labels to the prometheus - exporter. +* [EXPORTER] prometheus: add otel_scope_name and otel_scope_version labels [#2293](https://github.com/open-telemetry/opentelemetry-cpp/pull/2293) +* [EXPORTER] Export resource for prometheus + [#2301](https://github.com/open-telemetry/opentelemetry-cpp/pull/2301) +* [BUILD] error: read-only reference ‘value’ used as ‘asm’ output + [#2354](https://github.com/open-telemetry/opentelemetry-cpp/pull/2354) +* [BUILD] Build break with external CMake nlohman_json package + [#2353](https://github.com/open-telemetry/opentelemetry-cpp/pull/2353) +* [BUILD] Upgrade libcurl to version 8.4.0 + [#2358](https://github.com/open-telemetry/opentelemetry-cpp/pull/2358) +* [BUILD] Fix opentracing-shim when added in super project + [#2356](https://github.com/open-telemetry/opentelemetry-cpp/pull/2356) +* [BUILD] Fix protoc searching with non-imported protobuf::protoc target + [#2362](https://github.com/open-telemetry/opentelemetry-cpp/pull/2362) +* [BUILD] Support to use different cmake package CONFIG of dependencies + [#2263](https://github.com/open-telemetry/opentelemetry-cpp/pull/2263) +* [SEMANTIC CONVENTION] Upgrade to semconv 1.22.0 + [#2368](https://github.com/open-telemetry/opentelemetry-cpp/pull/2368) Important changes: @@ -70,6 +181,11 @@ Breaking changes: [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) * Building with C++11 is no longer supported. +Deprecations: + +* [DEPRECATION] Deprecate ZPAGES + [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) + ## [1.11.0] 2023-08-21 * [BUILD] Fix more cases for symbol name for 32-bit win32 DLL build diff --git a/CMakeLists.txt b/CMakeLists.txt index 10c1a0ab6f..b72e58a963 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,12 +275,12 @@ endif() option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF) -# EXPERIMENTAL -option(WITH_OTLP_HTTP_SSL_PREVIEW "Whether to enable otlp http ssl export" OFF) +# STABLE +option(WITH_OTLP_HTTP_SSL_PREVIEW "Whether to enable otlp http ssl export" ON) -# EXPERIMENTAL +# STABLE option(WITH_OTLP_HTTP_SSL_TLS_PREVIEW - "Whether to enable otlp http ssl tls min/max/cipher options" OFF) + "Whether to enable otlp http ssl tls min/max/cipher options" ON) # Exemplar specs status is experimental, so behind feature flag by default option(WITH_METRICS_EXEMPLAR_PREVIEW @@ -430,6 +430,11 @@ if(WITH_OTLP_GRPC OR WITH_OTLP_HTTP) if(TARGET protobuf::protoc) project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) + # If protobuf::protoc is not a imported target, then we use the target + # directly for fallback + if(NOT PROTOBUF_PROTOC_EXECUTABLE) + set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) + endif() elseif(Protobuf_PROTOC_EXECUTABLE) # Some versions of FindProtobuf.cmake uses mixed case instead of uppercase set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) @@ -683,6 +688,7 @@ if(NOT WITH_API_ONLY) endif() include(cmake/opentelemetry-build-external-component.cmake) +include(cmake/patch-imported-config.cmake) if(OPENTELEMETRY_INSTALL) # Export cmake config and support find_packages(opentelemetry-cpp CONFIG) diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index dd1eda3c78..ecbb377725 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -114,11 +114,6 @@ if(WITH_ASYNC_EXPORT_PREVIEW) target_compile_definitions(opentelemetry_api INTERFACE ENABLE_ASYNC_EXPORT) endif() -if(WITH_REMOVE_METER_PREVIEW) - target_compile_definitions(opentelemetry_api - INTERFACE ENABLE_REMOVE_METER_PREVIEW) -endif() - target_compile_definitions( opentelemetry_api INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO}) diff --git a/api/include/opentelemetry/metrics/meter_provider.h b/api/include/opentelemetry/metrics/meter_provider.h index 152e543d36..fca960bb8e 100644 --- a/api/include/opentelemetry/metrics/meter_provider.h +++ b/api/include/opentelemetry/metrics/meter_provider.h @@ -126,7 +126,19 @@ class MeterProvider nostd::string_view schema_url = "") noexcept = 0; #endif -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + /** + * Remove a named Meter instance (ABI). + * + * This API is experimental, see + * https://github.com/open-telemetry/opentelemetry-specification/issues/2232 + * + * @since ABI_VERSION 2 + * + * @param[in] name Meter instrumentation scope + * @param[in] version Instrumentation scope version, optional + * @param[in] schema_url Instrumentation scope schema URL, optional + */ virtual void RemoveMeter(nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "") noexcept = 0; diff --git a/api/include/opentelemetry/metrics/noop.h b/api/include/opentelemetry/metrics/noop.h index edbbe2c100..f20e855cb7 100644 --- a/api/include/opentelemetry/metrics/noop.h +++ b/api/include/opentelemetry/metrics/noop.h @@ -214,7 +214,7 @@ class NoopMeterProvider final : public MeterProvider } #endif -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 void RemoveMeter(nostd::string_view /* name */, nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override diff --git a/api/include/opentelemetry/plugin/tracer.h b/api/include/opentelemetry/plugin/tracer.h index b87f9e889f..068b08071d 100644 --- a/api/include/opentelemetry/plugin/tracer.h +++ b/api/include/opentelemetry/plugin/tracer.h @@ -7,6 +7,7 @@ #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/plugin/detail/tracer_handle.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" #include "opentelemetry/trace/tracer.h" #include "opentelemetry/version.h" @@ -49,6 +50,19 @@ class Span final : public trace::Span span_->AddEvent(name, timestamp, attributes); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const trace::SpanContext &target, + const common::KeyValueIterable &attrs) noexcept override + { + span_->AddLink(target, attrs); + } + + void AddLinks(const trace::SpanContextKeyValueIterable &links) noexcept override + { + span_->AddLinks(links); + } +#endif + void SetStatus(trace::StatusCode code, nostd::string_view description) noexcept override { span_->SetStatus(code, description); diff --git a/api/include/opentelemetry/trace/canonical_code.h b/api/include/opentelemetry/trace/canonical_code.h deleted file mode 100644 index fd722891d6..0000000000 --- a/api/include/opentelemetry/trace/canonical_code.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace trace -{ -enum class CanonicalCode : uint8_t -{ - /** - * The operation completed successfully. - */ - OK = 0, - - /** - * The operation was cancelled (typically by the caller). - */ - CANCELLED = 1, - - /** - * Unknown error. An example of where this error may be returned is if a Status value received - * from another address space belongs to an error-space that is not known in this address space. - * Also errors raised by APIs that do not return enough error information may be converted to - * this error. - */ - UNKNOWN = 2, - - /** - * Client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. - * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the - * system (e.g., a malformed file name). - */ - INVALID_ARGUMENT = 3, - - /** - * Deadline expired before operation could complete. For operations that change the state of the - * system, this error may be returned even if the operation has completed successfully. For - * example, a successful response from a server could have been delayed long enough for the - * deadline to expire. - */ - DEADLINE_EXCEEDED = 4, - - /** - * Some requested entity (e.g., file or directory) was not found. - */ - NOT_FOUND = 5, - - /** - * Some entity that we attempted to create (e.g., file or directory) already exists. - */ - ALREADY_EXISTS = 6, - - /** - * The caller does not have permission to execute the specified operation. PERMISSION_DENIED - * must not be used for rejections caused by exhausting some resource (use RESOURCE_EXHAUSTED - * instead for those errors). PERMISSION_DENIED must not be used if the caller cannot be - * identified (use UNAUTHENTICATED instead for those errors). - */ - PERMISSION_DENIED = 7, - - /** - * Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system - * is out of space. - */ - RESOURCE_EXHAUSTED = 8, - - /** - * Operation was rejected because the system is not in a state required for the operation's - * execution. For example, directory to be deleted may be non-empty, an rmdir operation is - * applied to a non-directory, etc. - * - * A litmus test that may help a service implementor in deciding between FAILED_PRECONDITION, - * ABORTED, and UNAVAILABLE: (a) Use UNAVAILABLE if the client can retry just the failing call. - * (b) Use ABORTED if the client should retry at a higher-level (e.g., restarting a - * read-modify-write sequence). (c) Use FAILED_PRECONDITION if the client should not retry until - * the system state has been explicitly fixed. E.g., if an "rmdir" fails because the directory - * is non-empty, FAILED_PRECONDITION should be returned since the client should not retry unless - * they have first fixed up the directory by deleting files from it. - */ - FAILED_PRECONDITION = 9, - - /** - * The operation was aborted, typically due to a concurrency issue like sequencer check - * failures, transaction aborts, etc. - * - * See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE. - */ - ABORTED = 10, - - /** - * Operation was attempted past the valid range. E.g., seeking or reading past end of file. - * - * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system - * state changes. For example, a 32-bit file system will generate INVALID_ARGUMENT if asked to - * read at an offset that is not in the range [0,2^32-1], but it will generate OUT_OF_RANGE if - * asked to read from an offset past the current file size. - * - * There is a fair bit of overlap between FAILED_PRECONDITION and OUT_OF_RANGE. We recommend - * using OUT_OF_RANGE (the more specific error) when it applies so that callers who are - * iterating through a space can easily look for an OUT_OF_RANGE error to detect when they are - * done. - */ - OUT_OF_RANGE = 11, - - /** - * Operation is not implemented or not supported/enabled in this service. - */ - UNIMPLEMENTED = 12, - - /** - * Internal errors. Means some invariants expected by underlying system has been broken. If you - * see one of these errors, something is very broken. - */ - INTERNAL = 13, - - /** - * The service is currently unavailable. This is a most likely a transient condition and may be - * corrected by retrying with a backoff. - * - * See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE. - */ - UNAVAILABLE = 14, - - /** - * Unrecoverable data loss or corruption. - */ - DATA_LOSS = 15, - - /** - * The request does not have valid authentication credentials for the operation. - */ - UNAUTHENTICATED = 16, -}; - -} // namespace trace -OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/trace/default_span.h b/api/include/opentelemetry/trace/default_span.h index cccc7951ad..7e3979501e 100644 --- a/api/include/opentelemetry/trace/default_span.h +++ b/api/include/opentelemetry/trace/default_span.h @@ -47,6 +47,14 @@ class DefaultSpan : public Span const common::KeyValueIterable & /* attributes */) noexcept override {} +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const SpanContext & /* target */, + const common::KeyValueIterable & /* attrs */) noexcept override + {} + + void AddLinks(const SpanContextKeyValueIterable & /* links */) noexcept override {} +#endif + void SetStatus(StatusCode /* status */, nostd::string_view /* description */) noexcept override {} void UpdateName(nostd::string_view /* name */) noexcept override {} diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index 2a2b7312ba..407f3c1ac9 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -15,6 +15,7 @@ #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" #include "opentelemetry/trace/tracer.h" #include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" @@ -58,6 +59,14 @@ class OPENTELEMETRY_EXPORT NoopSpan final : public Span const common::KeyValueIterable & /*attributes*/) noexcept override {} +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const SpanContext & /* target */, + const common::KeyValueIterable & /* attrs */) noexcept override + {} + + void AddLinks(const SpanContextKeyValueIterable & /* links */) noexcept override {} +#endif + void SetStatus(StatusCode /*code*/, nostd::string_view /*description*/) noexcept override {} void UpdateName(nostd::string_view /*name*/) noexcept override {} @@ -108,12 +117,23 @@ class OPENTELEMETRY_EXPORT NoopTracerProvider final : public trace::TracerProvid : tracer_{nostd::shared_ptr(new trace::NoopTracer)} {} - nostd::shared_ptr GetTracer(nostd::string_view /* library_name */, - nostd::string_view /* library_version */, +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::shared_ptr GetTracer( + nostd::string_view /* name */, + nostd::string_view /* version */, + nostd::string_view /* schema_url */, + const common::KeyValueIterable * /* attributes */) noexcept override + { + return tracer_; + } +#else + nostd::shared_ptr GetTracer(nostd::string_view /* name */, + nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override { return tracer_; } +#endif private: nostd::shared_ptr tracer_; diff --git a/api/include/opentelemetry/trace/semantic_conventions.h b/api/include/opentelemetry/trace/semantic_conventions.h index c46b41bc52..16d6562ee9 100644 --- a/api/include/opentelemetry/trace/semantic_conventions.h +++ b/api/include/opentelemetry/trace/semantic_conventions.h @@ -22,285 +22,291 @@ namespace SemanticConventions /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.21.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.22.0"; /** - * Client address - unix domain socket name, IPv4 or IPv6 address. + * Client address - domain name if available without reverse DNS lookup, otherwise IP address or + Unix domain socket name. * *

Notes:

  • When observed from the server side, and when communicating through an intermediary, - {@code client.address} SHOULD represent client address behind any intermediaries (e.g. proxies) if - it's available.
+ {@code client.address} SHOULD represent the client address behind any intermediaries (e.g. proxies) + if it's available. */ static constexpr const char *kClientAddress = "client.address"; /** - * Client port number + * Client port number. * *

Notes:

  • When observed from the server side, and when communicating through an intermediary, - {@code client.port} SHOULD represent client port behind any intermediaries (e.g. proxies) if it's - available.
+ {@code client.port} SHOULD represent the client port behind any intermediaries (e.g. proxies) if + it's available. */ static constexpr const char *kClientPort = "client.port"; /** - * Immediate client peer address - unix domain socket name, IPv4 or IPv6 address. - */ -static constexpr const char *kClientSocketAddress = "client.socket.address"; - -/** - * Immediate client peer port number + * Deprecated, use {@code server.address}. + * + * @deprecated Deprecated, use `server.address`. */ -static constexpr const char *kClientSocketPort = "client.socket.port"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostName = "net.host.name"; /** - * Deprecated, use {@code http.request.method} instead. + * Deprecated, use {@code server.port}. * - * @deprecated Deprecated, use `http.request.method` instead. + * @deprecated Deprecated, use `server.port`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpMethod = "http.method"; +static constexpr const char *kNetHostPort = "net.host.port"; /** - * Deprecated, use {@code http.response.status_code} instead. + * Deprecated, use {@code server.address} on client spans and {@code client.address} on server + * spans. * - * @deprecated Deprecated, use `http.response.status_code` instead. + * @deprecated Deprecated, use `server.address` on client spans and `client.address` on server + * spans. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpStatusCode = "http.status_code"; +static constexpr const char *kNetPeerName = "net.peer.name"; /** - * Deprecated, use {@code url.scheme} instead. + * Deprecated, use {@code server.port} on client spans and {@code client.port} on server spans. * - * @deprecated Deprecated, use `url.scheme` instead. + * @deprecated Deprecated, use `server.port` on client spans and `client.port` on server spans. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpScheme = "http.scheme"; +static constexpr const char *kNetPeerPort = "net.peer.port"; /** - * Deprecated, use {@code url.full} instead. + * Deprecated, use {@code network.protocol.name}. * - * @deprecated Deprecated, use `url.full` instead. + * @deprecated Deprecated, use `network.protocol.name`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpUrl = "http.url"; +static constexpr const char *kNetProtocolName = "net.protocol.name"; /** - * Deprecated, use {@code url.path} and {@code url.query} instead. + * Deprecated, use {@code network.protocol.version}. * - * @deprecated Deprecated, use `url.path` and `url.query` instead. + * @deprecated Deprecated, use `network.protocol.version`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpTarget = "http.target"; +static constexpr const char *kNetProtocolVersion = "net.protocol.version"; /** - * Deprecated, use {@code http.request.body.size} instead. + * Deprecated, use {@code network.transport} and {@code network.type}. * - * @deprecated Deprecated, use `http.request.body.size` instead. + * @deprecated Deprecated, use `network.transport` and `network.type`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; +static constexpr const char *kNetSockFamily = "net.sock.family"; /** - * Deprecated, use {@code http.response.body.size} instead. + * Deprecated, use {@code network.local.address}. * - * @deprecated Deprecated, use `http.response.body.size` instead. + * @deprecated Deprecated, use `network.local.address`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; +static constexpr const char *kNetSockHostAddr = "net.sock.host.addr"; /** - * Deprecated, use {@code server.socket.domain} on client spans. + * Deprecated, use {@code network.local.port}. * - * @deprecated Deprecated, use `server.socket.domain` on client spans. + * @deprecated Deprecated, use `network.local.port`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockPeerName = "net.sock.peer.name"; +static constexpr const char *kNetSockHostPort = "net.sock.host.port"; /** - * Deprecated, use {@code server.socket.address} on client spans and {@code client.socket.address} - * on server spans. + * Deprecated, use {@code network.peer.address}. * - * @deprecated Deprecated, use `server.socket.address` on client spans and `client.socket.address` - * on server spans. + * @deprecated Deprecated, use `network.peer.address`. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kNetSockPeerAddr = "net.sock.peer.addr"; /** - * Deprecated, use {@code server.socket.port} on client spans and {@code client.socket.port} on - * server spans. + * Deprecated, no replacement at this time. * - * @deprecated Deprecated, use `server.socket.port` on client spans and `client.socket.port` on - * server spans. + * @deprecated Deprecated, no replacement at this time. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; +static constexpr const char *kNetSockPeerName = "net.sock.peer.name"; /** - * Deprecated, use {@code server.address} on client spans and {@code client.address} on server - * spans. + * Deprecated, use {@code network.peer.port}. * - * @deprecated Deprecated, use `server.address` on client spans and `client.address` on server - * spans. + * @deprecated Deprecated, use `network.peer.port`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetPeerName = "net.peer.name"; +static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; /** - * Deprecated, use {@code server.port} on client spans and {@code client.port} on server spans. + * Deprecated, use {@code network.transport}. * - * @deprecated Deprecated, use `server.port` on client spans and `client.port` on server spans. + * @deprecated Deprecated, use `network.transport`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetPeerPort = "net.peer.port"; +static constexpr const char *kNetTransport = "net.transport"; /** - * Deprecated, use {@code server.address}. + * Destination address - domain name if available without reverse DNS lookup, otherwise IP address + or Unix domain socket name. * - * @deprecated Deprecated, use `server.address`. + *

Notes: +

  • When observed from the source side, and when communicating through an intermediary, + {@code destination.address} SHOULD represent the destination address behind any intermediaries + (e.g. proxies) if it's available.
*/ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetHostName = "net.host.name"; +static constexpr const char *kDestinationAddress = "destination.address"; /** - * Deprecated, use {@code server.port}. - * - * @deprecated Deprecated, use `server.port`. + * Destination port number */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetHostPort = "net.host.port"; +static constexpr const char *kDestinationPort = "destination.port"; /** - * Deprecated, use {@code server.socket.address}. + * Describes a class of error the operation ended with. * - * @deprecated Deprecated, use `server.socket.address`. + *

Notes: +

  • The {@code error.type} SHOULD be predictable and SHOULD have low cardinality. +Instrumentations SHOULD document the list of errors they report.
  • The cardinality of {@code +error.type} within one instrumentation library SHOULD be low, but telemetry consumers that aggregate +data from multiple instrumentation libraries and applications should be prepared for {@code +error.type} to have high cardinality at query time, when no additional filters are +applied.
  • If the operation has completed successfully, instrumentations SHOULD NOT set {@code +error.type}.
  • If a specific domain defines its own set of error codes (such as HTTP or gRPC +status codes), it's RECOMMENDED to use a domain-specific attribute and also set {@code error.type} +to capture all errors, regardless of whether they are defined within the domain-specific set or +not.
*/ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockHostAddr = "net.sock.host.addr"; +static constexpr const char *kErrorType = "error.type"; /** - * Deprecated, use {@code server.socket.port}. - * - * @deprecated Deprecated, use `server.socket.port`. + * The exception message. */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockHostPort = "net.sock.host.port"; +static constexpr const char *kExceptionMessage = "exception.message"; /** - * Deprecated, use {@code network.transport}. - * - * @deprecated Deprecated, use `network.transport`. + * 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. */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetTransport = "net.transport"; +static constexpr const char *kExceptionStacktrace = "exception.stacktrace"; /** - * Deprecated, use {@code network.protocol.name}. - * - * @deprecated Deprecated, use `network.protocol.name`. + * 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. */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetProtocolName = "net.protocol.name"; +static constexpr const char *kExceptionType = "exception.type"; /** - * Deprecated, use {@code network.protocol.version}. + * The name of the invoked function. * - * @deprecated Deprecated, use `network.protocol.version`. + *

Notes: +

  • SHOULD be equal to the {@code faas.name} resource attribute of the invoked function.
  • +
*/ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetProtocolVersion = "net.protocol.version"; +static constexpr const char *kFaasInvokedName = "faas.invoked_name"; /** - * Deprecated, use {@code network.transport} and {@code network.type}. + * The cloud provider of the invoked function. * - * @deprecated Deprecated, use `network.transport` and `network.type`. + *

Notes: +

  • SHOULD be equal to the {@code cloud.provider} resource attribute of the invoked + function.
*/ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockFamily = "net.sock.family"; +static constexpr const char *kFaasInvokedProvider = "faas.invoked_provider"; /** - * The domain name of the destination system. + * The cloud region of the invoked function. * *

Notes: -

  • This value may be a host name, a fully qualified domain name, or another host naming - format.
+
  • SHOULD be equal to the {@code cloud.region} resource attribute of the invoked + function.
*/ -static constexpr const char *kDestinationDomain = "destination.domain"; +static constexpr const char *kFaasInvokedRegion = "faas.invoked_region"; /** - * Peer address, for example IP address or UNIX socket name. + * Type of the trigger which caused this function invocation. */ -static constexpr const char *kDestinationAddress = "destination.address"; +static constexpr const char *kFaasTrigger = "faas.trigger"; /** - * Peer port number + * The {@code service.name} of the remote service. + * SHOULD be equal to the actual {@code service.name} resource attribute of the remote service if + * any. */ -static constexpr const char *kDestinationPort = "destination.port"; +static constexpr const char *kPeerService = "peer.service"; /** - * 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. + * Username or client_id extracted from the access token or Authorization header in the inbound + * request from outside the system. */ -static constexpr const char *kExceptionType = "exception.type"; +static constexpr const char *kEnduserId = "enduser.id"; /** - * The exception message. + * Actual/assumed role the client is making the request under extracted from token or application + * security context. */ -static constexpr const char *kExceptionMessage = "exception.message"; +static constexpr const char *kEnduserRole = "enduser.role"; /** - * 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. + * 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 or an attribute + * value in a SAML 2.0 + * Assertion. */ -static constexpr const char *kExceptionStacktrace = "exception.stacktrace"; +static constexpr const char *kEnduserScope = "enduser.scope"; /** - * HTTP request method. - * - *

Notes: -

  • HTTP request method value SHOULD be "known" to the instrumentation. -By default, this convention defines "known" methods as the ones listed in RFC9110 and the PATCH method -defined in RFC5789.
  • If the HTTP -request method is not known to instrumentation, it MUST set the {@code http.request.method} -attribute to {@code _OTHER} and, except if reporting a metric, MUST set the exact method received in -the request line as value of the {@code http.request.method_original} attribute.
  • If the HTTP -instrumentation could end up converting valid HTTP request methods to {@code _OTHER}, then it MUST -provide a way to override the list of known HTTP methods. If this override is done via environment -variable, then the environment variable MUST be named OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and -support a comma-separated list of case-sensitive known HTTP methods (this list MUST be a full -override of the default known method, it is not a list of known methods in addition to the -defaults).
  • HTTP method names are case-sensitive and {@code http.request.method} attribute -value MUST match a known HTTP method name exactly. Instrumentations for specific web frameworks that -consider HTTP methods to be case insensitive, SHOULD populate a canonical equivalent. Tracing -instrumentations that do so, MUST also set {@code http.request.method_original} to the original -value.
+ * Whether the thread is daemon or not. */ -static constexpr const char *kHttpRequestMethod = "http.request.method"; +static constexpr const char *kThreadDaemon = "thread.daemon"; /** - * HTTP response status code. + * Current "managed" thread ID (as opposed to OS thread ID). */ -static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; +static constexpr const char *kThreadId = "thread.id"; /** - * The matched route (path template in the format used by the respective server framework). See note -below - * - *

Notes: -

  • MUST NOT be populated when this is not supported by the HTTP server framework as the -route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD include -the application root if there is -one.
+ * Current thread name. */ -static constexpr const char *kHttpRoute = "http.route"; +static constexpr const char *kThreadName = "thread.name"; /** - * The name identifies the event. + * The column number in {@code code.filepath} best representing the operation. It SHOULD point + * within the code unit named in {@code code.function}. */ -static constexpr const char *kEventName = "event.name"; +static constexpr const char *kCodeColumn = "code.column"; + +/** + * The source code file name that identifies the code unit as uniquely as possible (preferably an + * absolute file path). + */ +static constexpr const char *kCodeFilepath = "code.filepath"; + +/** + * The method or function name, or equivalent (usually rightmost part of the code unit's name). + */ +static constexpr const char *kCodeFunction = "code.function"; + +/** + * The line number in {@code code.filepath} best representing the operation. It SHOULD point within + * the code unit named in {@code code.function}. + */ +static constexpr const char *kCodeLineno = "code.lineno"; + +/** + * The "namespace" within which {@code code.function} is defined. Usually the qualified + * class or module name, such that {@code code.namespace} + some separator + {@code code.function} + * form a unique identifier for the code unit. + */ +static constexpr const char *kCodeNamespace = "code.namespace"; /** * The domain identifies the business context for the events. @@ -311,6 +317,11 @@ unrelated events. */ static constexpr const char *kEventDomain = "event.domain"; +/** + * The name identifies the event. + */ +static constexpr const char *kEventName = "event.name"; + /** * A unique identifier for the Log Record. * @@ -333,14 +344,14 @@ static constexpr const char *kLogIostream = "log.iostream"; static constexpr const char *kLogFileName = "log.file.name"; /** - * The full path to the file. + * The basename of the file, with symlinks resolved. */ -static constexpr const char *kLogFilePath = "log.file.path"; +static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; /** - * The basename of the file, with symlinks resolved. + * The full path to the file. */ -static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; +static constexpr const char *kLogFilePath = "log.file.path"; /** * The full path to the file, with symlinks resolved. @@ -348,9 +359,27 @@ static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; /** - * The type of memory. + * The name of the connection pool; unique within the instrumented application. In case the + * connection pool implementation does not provide a name, then the db.connection_string + * should be used + */ +static constexpr const char *kPoolName = "pool.name"; + +/** + * The state of a connection in the pool + */ +static constexpr const char *kState = "state"; + +/** + * Name of the buffer pool. + * + *

Notes: +

*/ -static constexpr const char *kType = "type"; +static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; /** * Name of the memory pool. @@ -360,570 +389,669 @@ static constexpr const char *kType = "type"; href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getName()">MemoryPoolMXBean#getName(). */ -static constexpr const char *kPool = "pool"; +static constexpr const char *kJvmMemoryPoolName = "jvm.memory.pool.name"; /** - * Logical server hostname, matches server FQDN if available, and IP or socket address if FQDN is - * not known. + * The type of memory. */ -static constexpr const char *kServerAddress = "server.address"; +static constexpr const char *kJvmMemoryType = "jvm.memory.type"; /** - * Logical server port number + * The device identifier */ -static constexpr const char *kServerPort = "server.port"; +static constexpr const char *kSystemDevice = "system.device"; /** - * The domain name of an immediate peer. - * - *

Notes: -

  • Typically observed from the client side, and represents a proxy or other intermediary - domain name.
+ * The logical CPU number [0..n-1] */ -static constexpr const char *kServerSocketDomain = "server.socket.domain"; +static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; /** - * Physical server IP address or Unix socket address. If set from the client, should simply use the - * socket's peer address, and not attempt to find any actual server IP (i.e., if set from client, - * this may represent some proxy server instead of the logical server). + * The state of the CPU */ -static constexpr const char *kServerSocketAddress = "server.socket.address"; +static constexpr const char *kSystemCpuState = "system.cpu.state"; /** - * Physical server port. + * The memory state */ -static constexpr const char *kServerSocketPort = "server.socket.port"; +static constexpr const char *kSystemMemoryState = "system.memory.state"; /** - * The domain name of the source system. - * - *

Notes: -

  • This value may be a host name, a fully qualified domain name, or another host naming - format.
+ * The paging access direction */ -static constexpr const char *kSourceDomain = "source.domain"; +static constexpr const char *kSystemPagingDirection = "system.paging.direction"; /** - * Source address, for example IP address or Unix socket name. + * The memory paging state */ -static constexpr const char *kSourceAddress = "source.address"; +static constexpr const char *kSystemPagingState = "system.paging.state"; /** - * Source port number + * The memory paging type */ -static constexpr const char *kSourcePort = "source.port"; +static constexpr const char *kSystemPagingType = "system.paging.type"; /** - * The full invoked ARN as provided on the {@code Context} passed to the function ({@code - Lambda-Runtime-Invoked-Function-Arn} header on the {@code /runtime/invocation/next} applicable). - * - *

Notes: -

  • This may be different from {@code cloud.resource_id} if an alias is involved.
+ * The disk operation direction */ -static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; +static constexpr const char *kSystemDiskDirection = "system.disk.direction"; /** - * The event_id - * uniquely identifies the event. + * The filesystem mode */ -static constexpr const char *kCloudeventsEventId = "cloudevents.event_id"; +static constexpr const char *kSystemFilesystemMode = "system.filesystem.mode"; /** - * The source - * identifies the context in which an event happened. + * The filesystem mount path */ -static constexpr const char *kCloudeventsEventSource = "cloudevents.event_source"; +static constexpr const char *kSystemFilesystemMountpoint = "system.filesystem.mountpoint"; /** - * The version of - * the CloudEvents specification which the event uses. + * The filesystem state */ -static constexpr const char *kCloudeventsEventSpecVersion = "cloudevents.event_spec_version"; +static constexpr const char *kSystemFilesystemState = "system.filesystem.state"; /** - * The event_type - * contains a value describing the type of event related to the originating occurrence. + * The filesystem type */ -static constexpr const char *kCloudeventsEventType = "cloudevents.event_type"; +static constexpr const char *kSystemFilesystemType = "system.filesystem.type"; /** - * The subject of - * the event in the context of the event producer (identified by source). + * */ -static constexpr const char *kCloudeventsEventSubject = "cloudevents.event_subject"; +static constexpr const char *kSystemNetworkDirection = "system.network.direction"; /** - * Parent-child Reference type - * - *

Notes: -

  • The causal relationship between a child Span and a parent Span.
+ * A stateless protocol MUST NOT set this attribute */ -static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; +static constexpr const char *kSystemNetworkState = "system.network.state"; /** - * An identifier for the database management system (DBMS) product being used. See below for a list - * of well-known identifiers. + * The process state, e.g., Linux Process State + * Codes */ -static constexpr const char *kDbSystem = "db.system"; +static constexpr const char *kSystemProcessesStatus = "system.processes.status"; /** - * The connection string used to connect to the database. It is recommended to remove embedded - * credentials. + * Local address of the network connection - IP address or Unix domain socket name. */ -static constexpr const char *kDbConnectionString = "db.connection_string"; +static constexpr const char *kNetworkLocalAddress = "network.local.address"; /** - * Username for accessing the database. + * Local port number of the network connection. */ -static constexpr const char *kDbUser = "db.user"; +static constexpr const char *kNetworkLocalPort = "network.local.port"; /** - * The fully-qualified class name of the Java Database Connectivity - * (JDBC) driver used to connect. + * Peer address of the network connection - IP address or Unix domain socket name. */ -static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; +static constexpr const char *kNetworkPeerAddress = "network.peer.address"; /** - * 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). + * Peer port number of the network connection. + */ +static constexpr const char *kNetworkPeerPort = "network.peer.port"; + +/** + * OSI application layer or non-OSI + equivalent. * *

Notes: -

  • In some SQL databases, the database name to be used is called "schema name". In - case there are multiple layers that could be considered for database name (e.g. Oracle instance - name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema - name).
+
  • The value SHOULD be normalized to lowercase.
*/ -static constexpr const char *kDbName = "db.name"; +static constexpr const char *kNetworkProtocolName = "network.protocol.name"; /** - * The database statement being executed. + * Version of the protocol specified in {@code network.protocol.name}. + * + *

Notes: +

  • {@code network.protocol.version} refers to the version of the protocol used and might be + different from the protocol client's version. If the HTTP client used has a version of {@code + 0.27.2}, but sends HTTP version {@code 1.1}, this attribute should be set to {@code 1.1}.
  • +
*/ -static constexpr const char *kDbStatement = "db.statement"; +static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; /** - * The name of the operation being executed, e.g. the MongoDB command - name such as {@code findAndModify}, or the SQL keyword. + * OSI transport layer or inter-process communication +method. * *

Notes: -

  • When setting this to an SQL keyword, it is not recommended to attempt any client-side - parsing of {@code 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.
+
  • The value SHOULD be normalized to lowercase.
  • Consider always setting the +transport when setting a port number, since a port number is ambiguous without knowing the +transport, for example different processes could be listening on TCP port 12345 and UDP port +12345.
*/ -static constexpr const char *kDbOperation = "db.operation"; +static constexpr const char *kNetworkTransport = "network.transport"; /** - * The Microsoft SQL Server instance - name connecting to. This name is used to determine the port of a named instance. + * OSI network layer or non-OSI equivalent. * *

Notes: -

  • If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required - (but still recommended if non-standard).
+
  • The value SHOULD be normalized to lowercase.
*/ -static constexpr const char *kDbMssqlInstanceName = "db.mssql.instance_name"; +static constexpr const char *kNetworkType = "network.type"; /** - * The fetch size used for paging, i.e. how many rows will be returned at once. + * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. */ -static constexpr const char *kDbCassandraPageSize = "db.cassandra.page_size"; +static constexpr const char *kNetworkCarrierIcc = "network.carrier.icc"; /** - * The consistency level of the query. Based on consistency values from CQL. + * The mobile carrier country code. */ -static constexpr const char *kDbCassandraConsistencyLevel = "db.cassandra.consistency_level"; +static constexpr const char *kNetworkCarrierMcc = "network.carrier.mcc"; /** - * The name of the primary table that the operation is acting upon, including the keyspace name (if - applicable). + * The mobile carrier network code. + */ +static constexpr const char *kNetworkCarrierMnc = "network.carrier.mnc"; + +/** + * The name of the mobile carrier. + */ +static constexpr const char *kNetworkCarrierName = "network.carrier.name"; + +/** + * This describes more details regarding the connection.type. It may be the type of cell technology + * connection, but it could be used for describing details about a wifi connection. + */ +static constexpr const char *kNetworkConnectionSubtype = "network.connection.subtype"; + +/** + * The internet connection type. + */ +static constexpr const char *kNetworkConnectionType = "network.connection.type"; + +/** + * Deprecated, use {@code http.request.method} instead. * - *

Notes: -

  • This mirrors the db.sql.table attribute but references cassandra rather than sql. It is - not recommended to attempt any client-side parsing of {@code 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.
+ * @deprecated Deprecated, use `http.request.method` instead. */ -static constexpr const char *kDbCassandraTable = "db.cassandra.table"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpMethod = "http.method"; /** - * Whether or not the query is idempotent. + * Deprecated, use {@code http.request.body.size} instead. + * + * @deprecated Deprecated, use `http.request.body.size` instead. */ -static constexpr const char *kDbCassandraIdempotence = "db.cassandra.idempotence"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; /** - * The number of times a query was speculatively executed. Not set or {@code 0} if the query was not - * executed speculatively. + * Deprecated, use {@code http.response.body.size} instead. + * + * @deprecated Deprecated, use `http.response.body.size` instead. */ -static constexpr const char *kDbCassandraSpeculativeExecutionCount = - "db.cassandra.speculative_execution_count"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; /** - * The ID of the coordinating node for a query. + * Deprecated, use {@code url.scheme} instead. + * + * @deprecated Deprecated, use `url.scheme` instead. */ -static constexpr const char *kDbCassandraCoordinatorId = "db.cassandra.coordinator.id"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpScheme = "http.scheme"; /** - * The data center of the coordinating node for a query. + * Deprecated, use {@code http.response.status_code} instead. + * + * @deprecated Deprecated, use `http.response.status_code` instead. */ -static constexpr const char *kDbCassandraCoordinatorDc = "db.cassandra.coordinator.dc"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpStatusCode = "http.status_code"; /** - * The index of the database being accessed as used in the {@code SELECT} command, provided as an integer. To be - * used instead of the generic {@code db.name} attribute. + * Deprecated, use {@code url.path} and {@code url.query} instead. + * + * @deprecated Deprecated, use `url.path` and `url.query` instead. */ -static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpTarget = "http.target"; /** - * The collection being accessed within the database stated in {@code db.name}. + * Deprecated, use {@code url.full} instead. + * + * @deprecated Deprecated, use `url.full` instead. */ -static constexpr const char *kDbMongodbCollection = "db.mongodb.collection"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpUrl = "http.url"; /** - * The name of the primary table that the operation is acting upon, including the database name (if - applicable). + * 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 + * header. For requests using transport encoding, this should be the compressed size. + */ +static constexpr const char *kHttpRequestBodySize = "http.request.body.size"; + +/** + * HTTP request method. * *

Notes: -

  • It is not recommended to attempt any client-side parsing of {@code 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.
+
  • HTTP request method value SHOULD be "known" to the instrumentation. +By default, this convention defines "known" methods as the ones listed in RFC9110 and the PATCH method +defined in RFC5789.
  • If the HTTP +request method is not known to instrumentation, it MUST set the {@code http.request.method} +attribute to {@code _OTHER}.
  • If the HTTP instrumentation could end up converting valid HTTP +request methods to {@code _OTHER}, then it MUST provide a way to override the list of known HTTP +methods. If this override is done via environment variable, then the environment variable MUST be +named OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a comma-separated list of case-sensitive +known HTTP methods (this list MUST be a full override of the default known method, it is not a list +of known methods in addition to the defaults).
  • HTTP method names are case-sensitive and +{@code http.request.method} attribute value MUST match a known HTTP method name exactly. +Instrumentations for specific web frameworks that consider HTTP methods to be case insensitive, +SHOULD populate a canonical equivalent. Tracing instrumentations that do so, MUST also set {@code +http.request.method_original} to the original value.
*/ -static constexpr const char *kDbSqlTable = "db.sql.table"; +static constexpr const char *kHttpRequestMethod = "http.request.method"; /** - * Unique Cosmos client instance id. + * Original HTTP method sent by the client in the request line. */ -static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; +static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original"; /** - * CosmosDB Operation Type. + * The ordinal number of request resending attempt (for any reason, including redirects). + * + *

Notes: +

  • The resend count SHOULD be updated each time an HTTP request gets resent by the client, + regardless of what was the cause of the resending (e.g. redirection, authorization failure, 503 + Server Unavailable, network issues, or any other).
*/ -static constexpr const char *kDbCosmosdbOperationType = "db.cosmosdb.operation_type"; +static constexpr const char *kHttpResendCount = "http.resend_count"; /** - * Cosmos client connection mode. + * 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 + * header. For requests using transport encoding, this should be the compressed size. */ -static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; +static constexpr const char *kHttpResponseBodySize = "http.response.body.size"; /** - * Cosmos DB container name. + * HTTP response status code. */ -static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; +static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; /** - * Request payload size in bytes + * The matched route (path template in the format used by the respective server framework). See note +below + * + *

Notes: +

  • MUST NOT be populated when this is not supported by the HTTP server framework as the +route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD include +the application root if there is +one.
*/ -static constexpr const char *kDbCosmosdbRequestContentLength = "db.cosmosdb.request_content_length"; +static constexpr const char *kHttpRoute = "http.route"; /** - * Cosmos DB status code. + * Server address - domain name if available without reverse DNS lookup, otherwise IP address or +Unix domain socket name. + * + *

Notes: +

  • When observed from the client side, and when communicating through an intermediary, +{@code server.address} SHOULD represent the server address behind any intermediaries (e.g. proxies) +if it's available.
*/ -static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; +static constexpr const char *kServerAddress = "server.address"; /** - * Cosmos DB sub status code. + * Server port number. + * + *

Notes: +

  • When observed from the client side, and when communicating through an intermediary, + {@code server.port} SHOULD represent the server port behind any intermediaries (e.g. proxies) if + it's available.
*/ -static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; +static constexpr const char *kServerPort = "server.port"; /** - * RU consumed for that operation + * A unique id to identify a session. */ -static constexpr const char *kDbCosmosdbRequestCharge = "db.cosmosdb.request_charge"; +static constexpr const char *kSessionId = "session.id"; /** - * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code - * is UNSET. + * Source address - domain name if available without reverse DNS lookup, otherwise IP address or + Unix domain socket name. + * + *

Notes: +

  • When observed from the destination side, and when communicating through an intermediary, + {@code source.address} SHOULD represent the source address behind any intermediaries (e.g. proxies) + if it's available.
*/ -static constexpr const char *kOtelStatusCode = "otel.status_code"; +static constexpr const char *kSourceAddress = "source.address"; /** - * Description of the Status if it has a value, otherwise not set. + * Source port number */ -static constexpr const char *kOtelStatusDescription = "otel.status_description"; +static constexpr const char *kSourcePort = "source.port"; /** - * Type of the trigger which caused this function invocation. + * The full invoked ARN as provided on the {@code Context} passed to the function ({@code + Lambda-Runtime-Invoked-Function-Arn} header on the {@code /runtime/invocation/next} applicable). * *

Notes: -

  • For the server/consumer span on the incoming side, -{@code faas.trigger} MUST be set.
  • Clients invoking FaaS instances usually cannot set {@code -faas.trigger}, since they would typically need to look in the payload to determine the event type. -If clients set it, it should be the same as the trigger that corresponding incoming would have -(i.e., this has nothing to do with the underlying transport used to make the API call to invoke the -lambda, which is often HTTP).
+
  • This may be different from {@code cloud.resource_id} if an alias is involved.
*/ -static constexpr const char *kFaasTrigger = "faas.trigger"; +static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; /** - * The invocation ID of the current function invocation. + * The event_id + * uniquely identifies the event. */ -static constexpr const char *kFaasInvocationId = "faas.invocation_id"; +static constexpr const char *kCloudeventsEventId = "cloudevents.event_id"; /** - * 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. + * The source + * identifies the context in which an event happened. */ -static constexpr const char *kFaasDocumentCollection = "faas.document.collection"; +static constexpr const char *kCloudeventsEventSource = "cloudevents.event_source"; /** - * Describes the type of the operation that was performed on the data. + * The version of + * the CloudEvents specification which the event uses. */ -static constexpr const char *kFaasDocumentOperation = "faas.document.operation"; +static constexpr const char *kCloudeventsEventSpecVersion = "cloudevents.event_spec_version"; /** - * A string containing the time when the data was accessed in the ISO 8601 format expressed in UTC. + * The subject of + * the event in the context of the event producer (identified by source). */ -static constexpr const char *kFaasDocumentTime = "faas.document.time"; +static constexpr const char *kCloudeventsEventSubject = "cloudevents.event_subject"; /** - * 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. + * The event_type + * contains a value describing the type of event related to the originating occurrence. */ -static constexpr const char *kFaasDocumentName = "faas.document.name"; +static constexpr const char *kCloudeventsEventType = "cloudevents.event_type"; /** - * A string containing the function invocation time in the ISO 8601 format expressed in UTC. + * Parent-child Reference type + * + *

Notes: +

  • The causal relationship between a child Span and a parent Span.
*/ -static constexpr const char *kFaasTime = "faas.time"; +static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; /** - * A string containing the schedule period as Cron - * Expression. + * The connection string used to connect to the database. It is recommended to remove embedded + * credentials. */ -static constexpr const char *kFaasCron = "faas.cron"; +static constexpr const char *kDbConnectionString = "db.connection_string"; /** - * A boolean that is true if the serverless function is executed for the first time (aka - * cold-start). + * The fully-qualified class name of the Java Database Connectivity + * (JDBC) driver used to connect. */ -static constexpr const char *kFaasColdstart = "faas.coldstart"; +static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; /** - * The name of the invoked function. + * 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). * *

Notes: -

  • SHOULD be equal to the {@code faas.name} resource attribute of the invoked function.
  • -
+
  • In some SQL databases, the database name to be used is called "schema name". In + case there are multiple layers that could be considered for database name (e.g. Oracle instance + name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema + name).
*/ -static constexpr const char *kFaasInvokedName = "faas.invoked_name"; +static constexpr const char *kDbName = "db.name"; /** - * The cloud provider of the invoked function. + * The name of the operation being executed, e.g. the MongoDB command + name such as {@code findAndModify}, or the SQL keyword. * *

Notes: -

  • SHOULD be equal to the {@code cloud.provider} resource attribute of the invoked - function.
+
  • When setting this to an SQL keyword, it is not recommended to attempt any client-side + parsing of {@code 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.
*/ -static constexpr const char *kFaasInvokedProvider = "faas.invoked_provider"; +static constexpr const char *kDbOperation = "db.operation"; /** - * The cloud region of the invoked function. + * The database statement being executed. + */ +static constexpr const char *kDbStatement = "db.statement"; + +/** + * An identifier for the database management system (DBMS) product being used. See below for a list + * of well-known identifiers. + */ +static constexpr const char *kDbSystem = "db.system"; + +/** + * Username for accessing the database. + */ +static constexpr const char *kDbUser = "db.user"; + +/** + * The Microsoft SQL Server instance + name connecting to. This name is used to determine the port of a named instance. * *

Notes: -

  • SHOULD be equal to the {@code cloud.region} resource attribute of the invoked - function.
+
  • If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required + (but still recommended if non-standard).
*/ -static constexpr const char *kFaasInvokedRegion = "faas.invoked_region"; +static constexpr const char *kDbMssqlInstanceName = "db.mssql.instance_name"; /** - * The unique identifier of the feature flag. + * The consistency level of the query. Based on consistency values from CQL. */ -static constexpr const char *kFeatureFlagKey = "feature_flag.key"; +static constexpr const char *kDbCassandraConsistencyLevel = "db.cassandra.consistency_level"; /** - * The name of the service provider that performs the flag evaluation. + * The data center of the coordinating node for a query. */ -static constexpr const char *kFeatureFlagProviderName = "feature_flag.provider_name"; +static constexpr const char *kDbCassandraCoordinatorDc = "db.cassandra.coordinator.dc"; /** - * SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the -value can be used. + * The ID of the coordinating node for a query. + */ +static constexpr const char *kDbCassandraCoordinatorId = "db.cassandra.coordinator.id"; + +/** + * Whether or not the query is idempotent. + */ +static constexpr const char *kDbCassandraIdempotence = "db.cassandra.idempotence"; + +/** + * The fetch size used for paging, i.e. how many rows will be returned at once. + */ +static constexpr const char *kDbCassandraPageSize = "db.cassandra.page_size"; + +/** + * The number of times a query was speculatively executed. Not set or {@code 0} if the query was not + * executed speculatively. + */ +static constexpr const char *kDbCassandraSpeculativeExecutionCount = + "db.cassandra.speculative_execution_count"; + +/** + * The name of the primary table that the operation is acting upon, including the keyspace name (if + applicable). * *

Notes: -

  • A semantic identifier, commonly referred to as a variant, provides a means -for referring to a value without including the value itself. This can -provide additional context for understanding the meaning behind a value. -For example, the variant {@code red} maybe be used for the value {@code #c05543}.
  • A -stringified version of the value can be used in situations where a semantic identifier is -unavailable. String representation of the value should be determined by the implementer.
+
  • This mirrors the db.sql.table attribute but references cassandra rather than sql. It is + not recommended to attempt any client-side parsing of {@code 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.
*/ -static constexpr const char *kFeatureFlagVariant = "feature_flag.variant"; +static constexpr const char *kDbCassandraTable = "db.cassandra.table"; /** - * OSI Transport Layer or Inter-process Communication - * method. The value SHOULD be normalized to lowercase. + * The index of the database being accessed as used in the {@code SELECT} command, provided as an integer. To be + * used instead of the generic {@code db.name} attribute. */ -static constexpr const char *kNetworkTransport = "network.transport"; +static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; /** - * OSI Network Layer or non-OSI equivalent. The - * value SHOULD be normalized to lowercase. + * The collection being accessed within the database stated in {@code db.name}. */ -static constexpr const char *kNetworkType = "network.type"; +static constexpr const char *kDbMongodbCollection = "db.mongodb.collection"; /** - * OSI Application Layer or non-OSI - * equivalent. The value SHOULD be normalized to lowercase. + * Represents the identifier of an Elasticsearch cluster. */ -static constexpr const char *kNetworkProtocolName = "network.protocol.name"; +static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; + +/** + * Represents the human-readable identifier of the node/instance to which a request was routed. + */ +static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.name"; /** - * Version of the application layer protocol used. See note below. + * The name of the primary table that the operation is acting upon, including the database name (if + applicable). * *

Notes: -

  • {@code network.protocol.version} refers to the version of the protocol used and might be - different from the protocol client's version. If the HTTP client used has a version of {@code - 0.27.2}, but sends HTTP version {@code 1.1}, this attribute should be set to {@code 1.1}.
  • -
+
  • It is not recommended to attempt any client-side parsing of {@code 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.
*/ -static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; +static constexpr const char *kDbSqlTable = "db.sql.table"; /** - * The internet connection type. + * Unique Cosmos client instance id. */ -static constexpr const char *kNetworkConnectionType = "network.connection.type"; +static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; /** - * This describes more details regarding the connection.type. It may be the type of cell technology - * connection, but it could be used for describing details about a wifi connection. + * Cosmos client connection mode. */ -static constexpr const char *kNetworkConnectionSubtype = "network.connection.subtype"; +static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; /** - * The name of the mobile carrier. + * Cosmos DB container name. */ -static constexpr const char *kNetworkCarrierName = "network.carrier.name"; +static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; /** - * The mobile carrier country code. + * CosmosDB Operation Type. */ -static constexpr const char *kNetworkCarrierMcc = "network.carrier.mcc"; +static constexpr const char *kDbCosmosdbOperationType = "db.cosmosdb.operation_type"; /** - * The mobile carrier network code. + * RU consumed for that operation */ -static constexpr const char *kNetworkCarrierMnc = "network.carrier.mnc"; +static constexpr const char *kDbCosmosdbRequestCharge = "db.cosmosdb.request_charge"; /** - * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. + * Request payload size in bytes */ -static constexpr const char *kNetworkCarrierIcc = "network.carrier.icc"; +static constexpr const char *kDbCosmosdbRequestContentLength = "db.cosmosdb.request_content_length"; /** - * The {@code service.name} of the remote service. - * SHOULD be equal to the actual {@code service.name} resource attribute of the remote service if - * any. + * Cosmos DB status code. */ -static constexpr const char *kPeerService = "peer.service"; +static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; /** - * Username or client_id extracted from the access token or Authorization header in the inbound - * request from outside the system. + * Cosmos DB sub status code. */ -static constexpr const char *kEnduserId = "enduser.id"; +static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; /** - * Actual/assumed role the client is making the request under extracted from token or application - * security context. + * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code + * is UNSET. */ -static constexpr const char *kEnduserRole = "enduser.role"; +static constexpr const char *kOtelStatusCode = "otel.status_code"; /** - * 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 or an attribute - * value in a SAML 2.0 - * Assertion. + * Description of the Status if it has a value, otherwise not set. */ -static constexpr const char *kEnduserScope = "enduser.scope"; +static constexpr const char *kOtelStatusDescription = "otel.status_description"; /** - * Current "managed" thread ID (as opposed to OS thread ID). + * The invocation ID of the current function invocation. */ -static constexpr const char *kThreadId = "thread.id"; +static constexpr const char *kFaasInvocationId = "faas.invocation_id"; /** - * Current thread name. + * 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. */ -static constexpr const char *kThreadName = "thread.name"; +static constexpr const char *kFaasDocumentCollection = "faas.document.collection"; /** - * The method or function name, or equivalent (usually rightmost part of the code unit's name). + * 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. */ -static constexpr const char *kCodeFunction = "code.function"; +static constexpr const char *kFaasDocumentName = "faas.document.name"; /** - * The "namespace" within which {@code code.function} is defined. Usually the qualified - * class or module name, such that {@code code.namespace} + some separator + {@code code.function} - * form a unique identifier for the code unit. + * Describes the type of the operation that was performed on the data. */ -static constexpr const char *kCodeNamespace = "code.namespace"; +static constexpr const char *kFaasDocumentOperation = "faas.document.operation"; /** - * The source code file name that identifies the code unit as uniquely as possible (preferably an - * absolute file path). + * A string containing the time when the data was accessed in the ISO 8601 format expressed in UTC. */ -static constexpr const char *kCodeFilepath = "code.filepath"; +static constexpr const char *kFaasDocumentTime = "faas.document.time"; /** - * The line number in {@code code.filepath} best representing the operation. It SHOULD point within - * the code unit named in {@code code.function}. + * A string containing the schedule period as Cron + * Expression. */ -static constexpr const char *kCodeLineno = "code.lineno"; +static constexpr const char *kFaasCron = "faas.cron"; /** - * The column number in {@code code.filepath} best representing the operation. It SHOULD point - * within the code unit named in {@code code.function}. + * A string containing the function invocation time in the ISO 8601 format expressed in UTC. */ -static constexpr const char *kCodeColumn = "code.column"; +static constexpr const char *kFaasTime = "faas.time"; /** - * Original HTTP method sent by the client in the request line. + * A boolean that is true if the serverless function is executed for the first time (aka + * cold-start). */ -static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original"; +static constexpr const char *kFaasColdstart = "faas.coldstart"; /** - * 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 - * header. For requests using transport encoding, this should be the compressed size. + * The unique identifier of the feature flag. */ -static constexpr const char *kHttpRequestBodySize = "http.request.body.size"; +static constexpr const char *kFeatureFlagKey = "feature_flag.key"; /** - * 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 - * header. For requests using transport encoding, this should be the compressed size. + * The name of the service provider that performs the flag evaluation. */ -static constexpr const char *kHttpResponseBodySize = "http.response.body.size"; +static constexpr const char *kFeatureFlagProviderName = "feature_flag.provider_name"; /** - * The ordinal number of request resending attempt (for any reason, including redirects). + * SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the +value can be used. * *

Notes: -

  • The resend count SHOULD be updated each time an HTTP request gets resent by the client, - regardless of what was the cause of the resending (e.g. redirection, authorization failure, 503 - Server Unavailable, network issues, or any other).
+
  • A semantic identifier, commonly referred to as a variant, provides a means +for referring to a value without including the value itself. This can +provide additional context for understanding the meaning behind a value. +For example, the variant {@code red} maybe be used for the value {@code #c05543}.
  • A +stringified version of the value can be used in situations where a semantic identifier is +unavailable. String representation of the value should be determined by the implementer.
*/ -static constexpr const char *kHttpResendCount = "http.resend_count"; +static constexpr const char *kFeatureFlagVariant = "feature_flag.variant"; /** * The AWS request ID as returned in the response headers {@code x-amz-request-id} or {@code @@ -932,37 +1060,35 @@ static constexpr const char *kHttpResendCount = "http.resend_count"; static constexpr const char *kAwsRequestId = "aws.request_id"; /** - * The keys in the {@code RequestItems} object field. + * The value of the {@code AttributesToGet} request parameter. */ -static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names"; +static constexpr const char *kAwsDynamodbAttributesToGet = "aws.dynamodb.attributes_to_get"; /** - * The JSON-serialized value of each item in the {@code ConsumedCapacity} response field. + * The value of the {@code ConsistentRead} request parameter. */ -static constexpr const char *kAwsDynamodbConsumedCapacity = "aws.dynamodb.consumed_capacity"; +static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consistent_read"; /** - * The JSON-serialized value of the {@code ItemCollectionMetrics} response field. + * The JSON-serialized value of each item in the {@code ConsumedCapacity} response field. */ -static constexpr const char *kAwsDynamodbItemCollectionMetrics = - "aws.dynamodb.item_collection_metrics"; +static constexpr const char *kAwsDynamodbConsumedCapacity = "aws.dynamodb.consumed_capacity"; /** - * The value of the {@code ProvisionedThroughput.ReadCapacityUnits} request parameter. + * The value of the {@code IndexName} request parameter. */ -static constexpr const char *kAwsDynamodbProvisionedReadCapacity = - "aws.dynamodb.provisioned_read_capacity"; +static constexpr const char *kAwsDynamodbIndexName = "aws.dynamodb.index_name"; /** - * The value of the {@code ProvisionedThroughput.WriteCapacityUnits} request parameter. + * The JSON-serialized value of the {@code ItemCollectionMetrics} response field. */ -static constexpr const char *kAwsDynamodbProvisionedWriteCapacity = - "aws.dynamodb.provisioned_write_capacity"; +static constexpr const char *kAwsDynamodbItemCollectionMetrics = + "aws.dynamodb.item_collection_metrics"; /** - * The value of the {@code ConsistentRead} request parameter. + * The value of the {@code Limit} request parameter. */ -static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consistent_read"; +static constexpr const char *kAwsDynamodbLimit = "aws.dynamodb.limit"; /** * The value of the {@code ProjectionExpression} request parameter. @@ -970,24 +1096,26 @@ static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consiste static constexpr const char *kAwsDynamodbProjection = "aws.dynamodb.projection"; /** - * The value of the {@code Limit} request parameter. + * The value of the {@code ProvisionedThroughput.ReadCapacityUnits} request parameter. */ -static constexpr const char *kAwsDynamodbLimit = "aws.dynamodb.limit"; +static constexpr const char *kAwsDynamodbProvisionedReadCapacity = + "aws.dynamodb.provisioned_read_capacity"; /** - * The value of the {@code AttributesToGet} request parameter. + * The value of the {@code ProvisionedThroughput.WriteCapacityUnits} request parameter. */ -static constexpr const char *kAwsDynamodbAttributesToGet = "aws.dynamodb.attributes_to_get"; +static constexpr const char *kAwsDynamodbProvisionedWriteCapacity = + "aws.dynamodb.provisioned_write_capacity"; /** - * The value of the {@code IndexName} request parameter. + * The value of the {@code Select} request parameter. */ -static constexpr const char *kAwsDynamodbIndexName = "aws.dynamodb.index_name"; +static constexpr const char *kAwsDynamodbSelect = "aws.dynamodb.select"; /** - * The value of the {@code Select} request parameter. + * The keys in the {@code RequestItems} object field. */ -static constexpr const char *kAwsDynamodbSelect = "aws.dynamodb.select"; +static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names"; /** * The JSON-serialized value of each item of the {@code GlobalSecondaryIndexes} request field @@ -1017,24 +1145,24 @@ static constexpr const char *kAwsDynamodbTableCount = "aws.dynamodb.table_count" static constexpr const char *kAwsDynamodbScanForward = "aws.dynamodb.scan_forward"; /** - * The value of the {@code Segment} request parameter. + * The value of the {@code Count} response parameter. */ -static constexpr const char *kAwsDynamodbSegment = "aws.dynamodb.segment"; +static constexpr const char *kAwsDynamodbCount = "aws.dynamodb.count"; /** - * The value of the {@code TotalSegments} request parameter. + * The value of the {@code ScannedCount} response parameter. */ -static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; +static constexpr const char *kAwsDynamodbScannedCount = "aws.dynamodb.scanned_count"; /** - * The value of the {@code Count} response parameter. + * The value of the {@code Segment} request parameter. */ -static constexpr const char *kAwsDynamodbCount = "aws.dynamodb.count"; +static constexpr const char *kAwsDynamodbSegment = "aws.dynamodb.segment"; /** - * The value of the {@code ScannedCount} response parameter. + * The value of the {@code TotalSegments} request parameter. */ -static constexpr const char *kAwsDynamodbScannedCount = "aws.dynamodb.scanned_count"; +static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; /** * The JSON-serialized value of each item in the {@code AttributeDefinitions} request field. @@ -1060,6 +1188,33 @@ except {@code list-buckets}. */ static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; +/** + * The source object (in the form {@code bucket}/{@code key}) for the copy operation. + * + *

Notes: +

+ */ +static constexpr const char *kAwsS3CopySource = "aws.s3.copy_source"; + +/** + * The delete request container that specifies the objects to be deleted. + * + *

Notes: +

+ */ +static constexpr const char *kAwsS3Delete = "aws.s3.delete"; + /** * The S3 object key the request refers to. Corresponds to the {@code --key} parameter of the S3 API operations. @@ -1098,19 +1253,19 @@ href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.ht static constexpr const char *kAwsS3Key = "aws.s3.key"; /** - * The source object (in the form {@code bucket}/{@code key}) for the copy operation. + * The part number of the part being uploaded in a multipart-upload operation. This is a positive +integer between 1 and 10,000. * *

Notes: -

+ */ -static constexpr const char *kAwsS3CopySource = "aws.s3.copy_source"; +static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; /** * Upload ID that identifies the multipart upload. @@ -1134,31 +1289,12 @@ href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.ht static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; /** - * The delete request container that specifies the objects to be deleted. - * - *

Notes: -

- */ -static constexpr const char *kAwsS3Delete = "aws.s3.delete"; - -/** - * The part number of the part being uploaded in a multipart-upload operation. This is a positive -integer between 1 and 10,000. + * The GraphQL document being executed. * *

Notes: -

+
  • The value may be sanitized to exclude sensitive information.
*/ -static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; +static constexpr const char *kGraphqlDocument = "graphql.document"; /** * The name of the operation being executed. @@ -1171,17 +1307,13 @@ static constexpr const char *kGraphqlOperationName = "graphql.operation.name"; static constexpr const char *kGraphqlOperationType = "graphql.operation.type"; /** - * The GraphQL document being executed. + * The size of the message body in bytes. * *

Notes: -

  • The value may be sanitized to exclude sensitive information.
- */ -static constexpr const char *kGraphqlDocument = "graphql.document"; - -/** - * A value used by the messaging system as an identifier for the message, represented as a string. +
  • This can refer to both the compressed or uncompressed body size. If both sizes are known, +the uncompressed body size should be used.
*/ -static constexpr const char *kMessagingMessageId = "messaging.message.id"; +static constexpr const char *kMessagingMessageBodySize = "messaging.message.body.size"; /** * The conversation ID identifying the conversation to which the @@ -1190,17 +1322,24 @@ static constexpr const char *kMessagingMessageId = "messaging.message.id"; static constexpr const char *kMessagingMessageConversationId = "messaging.message.conversation_id"; /** - * 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. + * The size of the message body and metadata in bytes. + * + *

Notes: +

  • This can refer to both the compressed or uncompressed size. If both sizes are known, the +uncompressed size should be used.
+ */ +static constexpr const char *kMessagingMessageEnvelopeSize = "messaging.message.envelope.size"; + +/** + * A value used by the messaging system as an identifier for the message, represented as a string. */ -static constexpr const char *kMessagingMessagePayloadSizeBytes = - "messaging.message.payload_size_bytes"; +static constexpr const char *kMessagingMessageId = "messaging.message.id"; /** - * The compressed size of the message payload in bytes. + * A boolean that is true if the message destination is anonymous (could be unnamed or have + * auto-generated name). */ -static constexpr const char *kMessagingMessagePayloadCompressedSizeBytes = - "messaging.message.payload_compressed_size_bytes"; +static constexpr const char *kMessagingDestinationAnonymous = "messaging.destination.anonymous"; /** * The message destination name @@ -1227,27 +1366,25 @@ static constexpr const char *kMessagingDestinationTemplate = "messaging.destinat * A boolean that is true if the message destination is temporary and might not exist anymore after * messages are processed. */ -static constexpr const char *kMessagingDestinationTemporary = "messaging.destination.temporary"; - -/** - * A boolean that is true if the message destination is anonymous (could be unnamed or have - * auto-generated name). - */ -static constexpr const char *kMessagingDestinationAnonymous = "messaging.destination.anonymous"; +static constexpr const char *kMessagingDestinationTemporary = "messaging.destination.temporary"; /** - * A string identifying the messaging system. + * A boolean that is true if the publish message destination is anonymous (could be unnamed or have + * auto-generated name). */ -static constexpr const char *kMessagingSystem = "messaging.system"; +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; /** - * A string identifying the kind of messaging operation as defined in the Operation names section above. + * The name of the original destination the message was published to * *

Notes: -

  • If a custom value is used, it MUST be of low cardinality.
+
  • The name SHOULD uniquely identify a specific queue, topic, or other entity within the +broker. If the broker does not have such notion, the original destination name SHOULD uniquely +identify the broker.
*/ -static constexpr const char *kMessagingOperation = "messaging.operation"; +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; /** * The number of messages sent, received, or processed in the scope of the batching operation. @@ -1267,22 +1404,24 @@ static constexpr const char *kMessagingBatchMessageCount = "messaging.batch.mess static constexpr const char *kMessagingClientId = "messaging.client_id"; /** - * RabbitMQ message routing key. + * A string identifying the kind of messaging operation as defined in the Operation names section above. + * + *

Notes: +

  • If a custom value is used, it MUST be of low cardinality.
*/ -static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = - "messaging.rabbitmq.destination.routing_key"; +static constexpr const char *kMessagingOperation = "messaging.operation"; /** - * Message keys in Kafka are used for grouping alike messages to ensure they're processed on the - same partition. They differ from {@code messaging.message.id} in that they're not unique. If the - key is {@code null}, the attribute MUST NOT be set. - * - *

Notes: -

  • 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.
  • -
+ * A string identifying the messaging system. */ -static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; +static constexpr const char *kMessagingSystem = "messaging.system"; + +/** + * RabbitMQ message routing key. + */ +static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = + "messaging.rabbitmq.destination.routing_key"; /** * Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not @@ -1296,6 +1435,18 @@ static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.con static constexpr const char *kMessagingKafkaDestinationPartition = "messaging.kafka.destination.partition"; +/** + * Message keys in Kafka are used for grouping alike messages to ensure they're processed on the + same partition. They differ from {@code messaging.message.id} in that they're not unique. If the + key is {@code null}, the attribute MUST NOT be set. + * + *

Notes: +

  • 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.
  • +
+ */ +static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; + /** * The offset of a record in the corresponding Kafka partition. */ @@ -1306,11 +1457,6 @@ static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.mes */ static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; -/** - * Namespace of RocketMQ resources, resources in different namespaces are individual. - */ -static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; - /** * Name of the RocketMQ producer/consumer group that is handling the message. The client type is * identified by the SpanKind. @@ -1318,10 +1464,10 @@ static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.n static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; /** - * The timestamp in milliseconds that the delay message is expected to be delivered to consumer. + * Model of message consumption. This only applies to consumer spans. */ -static constexpr const char *kMessagingRocketmqMessageDeliveryTimestamp = - "messaging.rocketmq.message.delivery_timestamp"; +static constexpr const char *kMessagingRocketmqConsumptionModel = + "messaging.rocketmq.consumption_model"; /** * The delay time level for delay message, which determines the message delay time. @@ -1329,6 +1475,12 @@ static constexpr const char *kMessagingRocketmqMessageDeliveryTimestamp = static constexpr const char *kMessagingRocketmqMessageDelayTimeLevel = "messaging.rocketmq.message.delay_time_level"; +/** + * The timestamp in milliseconds that the delay message is expected to be delivered to consumer. + */ +static constexpr const char *kMessagingRocketmqMessageDeliveryTimestamp = + "messaging.rocketmq.message.delivery_timestamp"; + /** * It is essential for FIFO message. Messages that belong to the same message group are always * processed one by one within the same consumer group. @@ -1336,9 +1488,9 @@ static constexpr const char *kMessagingRocketmqMessageDelayTimeLevel = static constexpr const char *kMessagingRocketmqMessageGroup = "messaging.rocketmq.message.group"; /** - * Type of message. + * Key(s) of message, another way to mark message besides message id. */ -static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq.message.type"; +static constexpr const char *kMessagingRocketmqMessageKeys = "messaging.rocketmq.message.keys"; /** * The secondary classifier of message besides topic. @@ -1346,20 +1498,26 @@ static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq static constexpr const char *kMessagingRocketmqMessageTag = "messaging.rocketmq.message.tag"; /** - * Key(s) of message, another way to mark message besides message id. + * Type of message. */ -static constexpr const char *kMessagingRocketmqMessageKeys = "messaging.rocketmq.message.keys"; +static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq.message.type"; /** - * Model of message consumption. This only applies to consumer spans. + * Namespace of RocketMQ resources, resources in different namespaces are individual. */ -static constexpr const char *kMessagingRocketmqConsumptionModel = - "messaging.rocketmq.consumption_model"; +static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; /** - * A string identifying the remoting system. See below for a list of well-known identifiers. + * The name of the (logical) method being called, must be equal to the $method part in the span + name. + * + *

Notes: +

  • This is the logical name of the method from the RPC interface perspective, which can be + different from the name of any implementing method/function. The {@code code.function} attribute + may be used to store the latter (e.g., method actually executing the call on the server side, RPC + client stub method on the client side).
*/ -static constexpr const char *kRpcSystem = "rpc.system"; +static constexpr const char *kRpcMethod = "rpc.method"; /** * The full (logical) name of the service being called, including its package name, if applicable. @@ -1374,16 +1532,9 @@ static constexpr const char *kRpcSystem = "rpc.system"; static constexpr const char *kRpcService = "rpc.service"; /** - * The name of the (logical) method being called, must be equal to the $method part in the span - name. - * - *

Notes: -

  • This is the logical name of the method from the RPC interface perspective, which can be - different from the name of any implementing method/function. The {@code code.function} attribute - may be used to store the latter (e.g., method actually executing the call on the server side, RPC - client stub method on the client side).
+ * A string identifying the remoting system. See below for a list of well-known identifiers. */ -static constexpr const char *kRpcMethod = "rpc.method"; +static constexpr const char *kRpcSystem = "rpc.system"; /** * The numeric status @@ -1392,10 +1543,14 @@ static constexpr const char *kRpcMethod = "rpc.method"; static constexpr const char *kRpcGrpcStatusCode = "rpc.grpc.status_code"; /** - * Protocol version as in {@code jsonrpc} property of request/response. Since JSON-RPC 1.0 does not - * specify this, the value can be omitted. + * {@code error.code} property of response if it is an error response. */ -static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; +static constexpr const char *kRpcJsonrpcErrorCode = "rpc.jsonrpc.error_code"; + +/** + * {@code error.message} property of response if it is an error response. + */ +static constexpr const char *kRpcJsonrpcErrorMessage = "rpc.jsonrpc.error_message"; /** * {@code id} property of request or response. Since protocol allows id to be int, string, {@code @@ -1405,19 +1560,15 @@ static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; static constexpr const char *kRpcJsonrpcRequestId = "rpc.jsonrpc.request_id"; /** - * {@code error.code} property of response if it is an error response. - */ -static constexpr const char *kRpcJsonrpcErrorCode = "rpc.jsonrpc.error_code"; - -/** - * {@code error.message} property of response if it is an error response. + * Protocol version as in {@code jsonrpc} property of request/response. Since JSON-RPC 1.0 does not + * specify this, the value can be omitted. */ -static constexpr const char *kRpcJsonrpcErrorMessage = "rpc.jsonrpc.error_message"; +static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; /** - * Whether this is a received or sent message. + * Compressed size of the message in bytes. */ -static constexpr const char *kMessageType = "message.type"; +static constexpr const char *kMessageCompressedSize = "message.compressed_size"; /** * MUST be calculated as two different counters starting from {@code 1} one for sent messages and @@ -1430,9 +1581,9 @@ static constexpr const char *kMessageType = "message.type"; static constexpr const char *kMessageId = "message.id"; /** - * Compressed size of the message in bytes. + * Whether this is a received or sent message. */ -static constexpr const char *kMessageCompressedSize = "message.compressed_size"; +static constexpr const char *kMessageType = "message.type"; /** * Uncompressed size of the message in bytes. @@ -1465,10 +1616,9 @@ recorded at a time where it was not clear whether the exception will escape.URI scheme component - * identifying the used protocol. + * The URI fragment component */ -static constexpr const char *kUrlScheme = "url.scheme"; +static constexpr const char *kUrlFragment = "url.fragment"; /** * Absolute URL describing a network resource according to URI fragment component + * The URI scheme component + * identifying the used protocol. */ -static constexpr const char *kUrlFragment = "url.fragment"; +static constexpr const char *kUrlScheme = "url.scheme"; + +/** + * Value of the HTTP + * User-Agent header sent by the client. + */ +static constexpr const char *kUserAgentOriginal = "user_agent.original"; + +// Enum definitions +namespace NetSockFamilyValues +{ +/** IPv4 address. */ +static constexpr const char *kInet = "inet"; +/** IPv6 address. */ +static constexpr const char *kInet6 = "inet6"; +/** Unix domain socket path. */ +static constexpr const char *kUnix = "unix"; +} // namespace NetSockFamilyValues + +namespace NetTransportValues +{ +/** ip_tcp. */ +static constexpr const char *kIpTcp = "ip_tcp"; +/** ip_udp. */ +static constexpr const char *kIpUdp = "ip_udp"; +/** Named or anonymous pipe. */ +static constexpr const char *kPipe = "pipe"; +/** In-process communication. */ +static constexpr const char *kInproc = "inproc"; +/** Something else (non IP-based). */ +static constexpr const char *kOther = "other"; +} // namespace NetTransportValues + +namespace ErrorTypeValues +{ +/** A fallback error value to be used when the instrumentation does not define a custom value for + * it. */ +static constexpr const char *kOther = "_OTHER"; +} // namespace ErrorTypeValues + +namespace FaasInvokedProviderValues +{ +/** Alibaba Cloud. */ +static constexpr const char *kAlibabaCloud = "alibaba_cloud"; +/** Amazon Web Services. */ +static constexpr const char *kAws = "aws"; +/** Microsoft Azure. */ +static constexpr const char *kAzure = "azure"; +/** Google Cloud Platform. */ +static constexpr const char *kGcp = "gcp"; +/** Tencent Cloud. */ +static constexpr const char *kTencentCloud = "tencent_cloud"; +} // namespace FaasInvokedProviderValues + +namespace FaasTriggerValues +{ +/** A response to some data source operation such as a database or filesystem read/write. */ +static constexpr const char *kDatasource = "datasource"; +/** To provide an answer to an inbound HTTP request. */ +static constexpr const char *kHttp = "http"; +/** A function is set to be executed when messages are sent to a messaging system. */ +static constexpr const char *kPubsub = "pubsub"; +/** A function is scheduled to be executed regularly. */ +static constexpr const char *kTimer = "timer"; +/** If none of the others apply. */ +static constexpr const char *kOther = "other"; +} // namespace FaasTriggerValues + +namespace EventDomainValues +{ +/** Events from browser apps. */ +static constexpr const char *kBrowser = "browser"; +/** Events from mobile apps. */ +static constexpr const char *kDevice = "device"; +/** Events from Kubernetes. */ +static constexpr const char *kK8s = "k8s"; +} // namespace EventDomainValues + +namespace LogIostreamValues +{ +/** Logs from stdout stream. */ +static constexpr const char *kStdout = "stdout"; +/** Events from stderr stream. */ +static constexpr const char *kStderr = "stderr"; +} // namespace LogIostreamValues + +namespace StateValues +{ +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** used. */ +static constexpr const char *kUsed = "used"; +} // namespace StateValues + +namespace JvmMemoryTypeValues +{ +/** Heap memory. */ +static constexpr const char *kHeap = "heap"; +/** Non-heap memory. */ +static constexpr const char *kNonHeap = "non_heap"; +} // namespace JvmMemoryTypeValues + +namespace SystemCpuStateValues +{ +/** user. */ +static constexpr const char *kUser = "user"; +/** system. */ +static constexpr const char *kSystem = "system"; +/** nice. */ +static constexpr const char *kNice = "nice"; +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** iowait. */ +static constexpr const char *kIowait = "iowait"; +/** interrupt. */ +static constexpr const char *kInterrupt = "interrupt"; +/** steal. */ +static constexpr const char *kSteal = "steal"; +} // namespace SystemCpuStateValues + +namespace SystemMemoryStateValues +{ +/** total. */ +static constexpr const char *kTotal = "total"; +/** used. */ +static constexpr const char *kUsed = "used"; +/** free. */ +static constexpr const char *kFree = "free"; +/** shared. */ +static constexpr const char *kShared = "shared"; +/** buffers. */ +static constexpr const char *kBuffers = "buffers"; +/** cached. */ +static constexpr const char *kCached = "cached"; +} // namespace SystemMemoryStateValues + +namespace SystemPagingDirectionValues +{ +/** in. */ +static constexpr const char *kIn = "in"; +/** out. */ +static constexpr const char *kOut = "out"; +} // namespace SystemPagingDirectionValues + +namespace SystemPagingStateValues +{ +/** used. */ +static constexpr const char *kUsed = "used"; +/** free. */ +static constexpr const char *kFree = "free"; +} // namespace SystemPagingStateValues + +namespace SystemPagingTypeValues +{ +/** major. */ +static constexpr const char *kMajor = "major"; +/** minor. */ +static constexpr const char *kMinor = "minor"; +} // namespace SystemPagingTypeValues + +namespace SystemDiskDirectionValues +{ +/** read. */ +static constexpr const char *kRead = "read"; +/** write. */ +static constexpr const char *kWrite = "write"; +} // namespace SystemDiskDirectionValues + +namespace SystemFilesystemStateValues +{ +/** used. */ +static constexpr const char *kUsed = "used"; +/** free. */ +static constexpr const char *kFree = "free"; +/** reserved. */ +static constexpr const char *kReserved = "reserved"; +} // namespace SystemFilesystemStateValues + +namespace SystemFilesystemTypeValues +{ +/** fat32. */ +static constexpr const char *kFat32 = "fat32"; +/** exfat. */ +static constexpr const char *kExfat = "exfat"; +/** ntfs. */ +static constexpr const char *kNtfs = "ntfs"; +/** refs. */ +static constexpr const char *kRefs = "refs"; +/** hfsplus. */ +static constexpr const char *kHfsplus = "hfsplus"; +/** ext4. */ +static constexpr const char *kExt4 = "ext4"; +} // namespace SystemFilesystemTypeValues + +namespace SystemNetworkDirectionValues +{ +/** transmit. */ +static constexpr const char *kTransmit = "transmit"; +/** receive. */ +static constexpr const char *kReceive = "receive"; +} // namespace SystemNetworkDirectionValues + +namespace SystemNetworkStateValues +{ +/** close. */ +static constexpr const char *kClose = "close"; +/** close_wait. */ +static constexpr const char *kCloseWait = "close_wait"; +/** closing. */ +static constexpr const char *kClosing = "closing"; +/** delete. */ +static constexpr const char *kDelete = "delete"; +/** established. */ +static constexpr const char *kEstablished = "established"; +/** fin_wait_1. */ +static constexpr const char *kFinWait1 = "fin_wait_1"; +/** fin_wait_2. */ +static constexpr const char *kFinWait2 = "fin_wait_2"; +/** last_ack. */ +static constexpr const char *kLastAck = "last_ack"; +/** listen. */ +static constexpr const char *kListen = "listen"; +/** syn_recv. */ +static constexpr const char *kSynRecv = "syn_recv"; +/** syn_sent. */ +static constexpr const char *kSynSent = "syn_sent"; +/** time_wait. */ +static constexpr const char *kTimeWait = "time_wait"; +} // namespace SystemNetworkStateValues + +namespace SystemProcessesStatusValues +{ +/** running. */ +static constexpr const char *kRunning = "running"; +/** sleeping. */ +static constexpr const char *kSleeping = "sleeping"; +/** stopped. */ +static constexpr const char *kStopped = "stopped"; +/** defunct. */ +static constexpr const char *kDefunct = "defunct"; +} // namespace SystemProcessesStatusValues + +namespace NetworkTransportValues +{ +/** TCP. */ +static constexpr const char *kTcp = "tcp"; +/** UDP. */ +static constexpr const char *kUdp = "udp"; +/** Named or anonymous pipe. See note below. */ +static constexpr const char *kPipe = "pipe"; +/** Unix domain socket. */ +static constexpr const char *kUnix = "unix"; +} // namespace NetworkTransportValues -/** - * Value of the HTTP - * User-Agent header sent by the client. - */ -static constexpr const char *kUserAgentOriginal = "user_agent.original"; +namespace NetworkTypeValues +{ +/** IPv4. */ +static constexpr const char *kIpv4 = "ipv4"; +/** IPv6. */ +static constexpr const char *kIpv6 = "ipv6"; +} // namespace NetworkTypeValues -// Enum definitions -namespace NetTransportValues +namespace NetworkConnectionSubtypeValues { -/** ip_tcp. */ -static constexpr const char *kIpTcp = "ip_tcp"; -/** ip_udp. */ -static constexpr const char *kIpUdp = "ip_udp"; -/** Named or anonymous pipe. */ -static constexpr const char *kPipe = "pipe"; -/** In-process communication. */ -static constexpr const char *kInproc = "inproc"; -/** Something else (non IP-based). */ -static constexpr const char *kOther = "other"; -} // namespace NetTransportValues +/** GPRS. */ +static constexpr const char *kGprs = "gprs"; +/** EDGE. */ +static constexpr const char *kEdge = "edge"; +/** UMTS. */ +static constexpr const char *kUmts = "umts"; +/** CDMA. */ +static constexpr const char *kCdma = "cdma"; +/** EVDO Rel. 0. */ +static constexpr const char *kEvdo0 = "evdo_0"; +/** EVDO Rev. A. */ +static constexpr const char *kEvdoA = "evdo_a"; +/** CDMA2000 1XRTT. */ +static constexpr const char *kCdma20001xrtt = "cdma2000_1xrtt"; +/** HSDPA. */ +static constexpr const char *kHsdpa = "hsdpa"; +/** HSUPA. */ +static constexpr const char *kHsupa = "hsupa"; +/** HSPA. */ +static constexpr const char *kHspa = "hspa"; +/** IDEN. */ +static constexpr const char *kIden = "iden"; +/** EVDO Rev. B. */ +static constexpr const char *kEvdoB = "evdo_b"; +/** LTE. */ +static constexpr const char *kLte = "lte"; +/** EHRPD. */ +static constexpr const char *kEhrpd = "ehrpd"; +/** HSPAP. */ +static constexpr const char *kHspap = "hspap"; +/** GSM. */ +static constexpr const char *kGsm = "gsm"; +/** TD-SCDMA. */ +static constexpr const char *kTdScdma = "td_scdma"; +/** IWLAN. */ +static constexpr const char *kIwlan = "iwlan"; +/** 5G NR (New Radio). */ +static constexpr const char *kNr = "nr"; +/** 5G NRNSA (New Radio Non-Standalone). */ +static constexpr const char *kNrnsa = "nrnsa"; +/** LTE CA. */ +static constexpr const char *kLteCa = "lte_ca"; +} // namespace NetworkConnectionSubtypeValues -namespace NetSockFamilyValues +namespace NetworkConnectionTypeValues { -/** IPv4 address. */ -static constexpr const char *kInet = "inet"; -/** IPv6 address. */ -static constexpr const char *kInet6 = "inet6"; -/** Unix domain socket path. */ -static constexpr const char *kUnix = "unix"; -} // namespace NetSockFamilyValues +/** wifi. */ +static constexpr const char *kWifi = "wifi"; +/** wired. */ +static constexpr const char *kWired = "wired"; +/** cell. */ +static constexpr const char *kCell = "cell"; +/** unavailable. */ +static constexpr const char *kUnavailable = "unavailable"; +/** unknown. */ +static constexpr const char *kUnknown = "unknown"; +} // namespace NetworkConnectionTypeValues namespace HttpRequestMethodValues { @@ -1563,32 +2003,6 @@ static constexpr const char *kTrace = "TRACE"; static constexpr const char *kOther = "_OTHER"; } // namespace HttpRequestMethodValues -namespace EventDomainValues -{ -/** Events from browser apps. */ -static constexpr const char *kBrowser = "browser"; -/** Events from mobile apps. */ -static constexpr const char *kDevice = "device"; -/** Events from Kubernetes. */ -static constexpr const char *kK8s = "k8s"; -} // namespace EventDomainValues - -namespace LogIostreamValues -{ -/** Logs from stdout stream. */ -static constexpr const char *kStdout = "stdout"; -/** Events from stderr stream. */ -static constexpr const char *kStderr = "stderr"; -} // namespace LogIostreamValues - -namespace TypeValues -{ -/** Heap memory. */ -static constexpr const char *kHeap = "heap"; -/** Non-heap memory. */ -static constexpr const char *kNonHeap = "non_heap"; -} // namespace TypeValues - namespace OpentracingRefTypeValues { /** The parent Span depends on the child Span in some capacity. */ @@ -1731,6 +2145,14 @@ static constexpr const char *kSerial = "serial"; static constexpr const char *kLocalSerial = "local_serial"; } // namespace DbCassandraConsistencyLevelValues +namespace DbCosmosdbConnectionModeValues +{ +/** Gateway (HTTP) connections mode. */ +static constexpr const char *kGateway = "gateway"; +/** Direct connection. */ +static constexpr const char *kDirect = "direct"; +} // namespace DbCosmosdbConnectionModeValues + namespace DbCosmosdbOperationTypeValues { /** invalid. */ @@ -1765,14 +2187,6 @@ static constexpr const char *kQueryPlan = "QueryPlan"; static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; } // namespace DbCosmosdbOperationTypeValues -namespace DbCosmosdbConnectionModeValues -{ -/** Gateway (HTTP) connections mode. */ -static constexpr const char *kGateway = "gateway"; -/** Direct connection. */ -static constexpr const char *kDirect = "direct"; -} // namespace DbCosmosdbConnectionModeValues - namespace OtelStatusCodeValues { /** The operation has been validated by an Application developer or Operator to have completed @@ -1782,20 +2196,6 @@ static constexpr const char *kOk = "OK"; static constexpr const char *kError = "ERROR"; } // namespace OtelStatusCodeValues -namespace FaasTriggerValues -{ -/** A response to some data source operation such as a database or filesystem read/write. */ -static constexpr const char *kDatasource = "datasource"; -/** To provide an answer to an inbound HTTP request. */ -static constexpr const char *kHttp = "http"; -/** A function is set to be executed when messages are sent to a messaging system. */ -static constexpr const char *kPubsub = "pubsub"; -/** A function is scheduled to be executed regularly. */ -static constexpr const char *kTimer = "timer"; -/** If none of the others apply. */ -static constexpr const char *kOther = "other"; -} // namespace FaasTriggerValues - namespace FaasDocumentOperationValues { /** When a new object is created. */ @@ -1806,100 +2206,6 @@ static constexpr const char *kEdit = "edit"; static constexpr const char *kDelete = "delete"; } // namespace FaasDocumentOperationValues -namespace FaasInvokedProviderValues -{ -/** Alibaba Cloud. */ -static constexpr const char *kAlibabaCloud = "alibaba_cloud"; -/** Amazon Web Services. */ -static constexpr const char *kAws = "aws"; -/** Microsoft Azure. */ -static constexpr const char *kAzure = "azure"; -/** Google Cloud Platform. */ -static constexpr const char *kGcp = "gcp"; -/** Tencent Cloud. */ -static constexpr const char *kTencentCloud = "tencent_cloud"; -} // namespace FaasInvokedProviderValues - -namespace NetworkTransportValues -{ -/** TCP. */ -static constexpr const char *kTcp = "tcp"; -/** UDP. */ -static constexpr const char *kUdp = "udp"; -/** Named or anonymous pipe. See note below. */ -static constexpr const char *kPipe = "pipe"; -/** Unix domain socket. */ -static constexpr const char *kUnix = "unix"; -} // namespace NetworkTransportValues - -namespace NetworkTypeValues -{ -/** IPv4. */ -static constexpr const char *kIpv4 = "ipv4"; -/** IPv6. */ -static constexpr const char *kIpv6 = "ipv6"; -} // namespace NetworkTypeValues - -namespace NetworkConnectionTypeValues -{ -/** wifi. */ -static constexpr const char *kWifi = "wifi"; -/** wired. */ -static constexpr const char *kWired = "wired"; -/** cell. */ -static constexpr const char *kCell = "cell"; -/** unavailable. */ -static constexpr const char *kUnavailable = "unavailable"; -/** unknown. */ -static constexpr const char *kUnknown = "unknown"; -} // namespace NetworkConnectionTypeValues - -namespace NetworkConnectionSubtypeValues -{ -/** GPRS. */ -static constexpr const char *kGprs = "gprs"; -/** EDGE. */ -static constexpr const char *kEdge = "edge"; -/** UMTS. */ -static constexpr const char *kUmts = "umts"; -/** CDMA. */ -static constexpr const char *kCdma = "cdma"; -/** EVDO Rel. 0. */ -static constexpr const char *kEvdo0 = "evdo_0"; -/** EVDO Rev. A. */ -static constexpr const char *kEvdoA = "evdo_a"; -/** CDMA2000 1XRTT. */ -static constexpr const char *kCdma20001xrtt = "cdma2000_1xrtt"; -/** HSDPA. */ -static constexpr const char *kHsdpa = "hsdpa"; -/** HSUPA. */ -static constexpr const char *kHsupa = "hsupa"; -/** HSPA. */ -static constexpr const char *kHspa = "hspa"; -/** IDEN. */ -static constexpr const char *kIden = "iden"; -/** EVDO Rev. B. */ -static constexpr const char *kEvdoB = "evdo_b"; -/** LTE. */ -static constexpr const char *kLte = "lte"; -/** EHRPD. */ -static constexpr const char *kEhrpd = "ehrpd"; -/** HSPAP. */ -static constexpr const char *kHspap = "hspap"; -/** GSM. */ -static constexpr const char *kGsm = "gsm"; -/** TD-SCDMA. */ -static constexpr const char *kTdScdma = "td_scdma"; -/** IWLAN. */ -static constexpr const char *kIwlan = "iwlan"; -/** 5G NR (New Radio). */ -static constexpr const char *kNr = "nr"; -/** 5G NRNSA (New Radio Non-Standalone). */ -static constexpr const char *kNrnsa = "nrnsa"; -/** LTE CA. */ -static constexpr const char *kLteCa = "lte_ca"; -} // namespace NetworkConnectionSubtypeValues - namespace GraphqlOperationTypeValues { /** GraphQL query. */ @@ -1920,6 +2226,14 @@ static constexpr const char *kReceive = "receive"; static constexpr const char *kProcess = "process"; } // namespace MessagingOperationValues +namespace MessagingRocketmqConsumptionModelValues +{ +/** Clustering consumption model. */ +static constexpr const char *kClustering = "clustering"; +/** Broadcasting consumption model. */ +static constexpr const char *kBroadcasting = "broadcasting"; +} // namespace MessagingRocketmqConsumptionModelValues + namespace MessagingRocketmqMessageTypeValues { /** Normal message. */ @@ -1932,14 +2246,6 @@ static constexpr const char *kDelay = "delay"; static constexpr const char *kTransaction = "transaction"; } // namespace MessagingRocketmqMessageTypeValues -namespace MessagingRocketmqConsumptionModelValues -{ -/** Clustering consumption model. */ -static constexpr const char *kClustering = "clustering"; -/** Broadcasting consumption model. */ -static constexpr const char *kBroadcasting = "broadcasting"; -} // namespace MessagingRocketmqConsumptionModelValues - namespace RpcSystemValues { /** gRPC. */ diff --git a/api/include/opentelemetry/trace/span.h b/api/include/opentelemetry/trace/span.h index ffd145a30d..27e91ceec4 100644 --- a/api/include/opentelemetry/trace/span.h +++ b/api/include/opentelemetry/trace/span.h @@ -10,8 +10,9 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/trace/canonical_code.h" #include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" +#include "opentelemetry/trace/span_context_kv_iterable_view.h" #include "opentelemetry/trace/span_metadata.h" #include "opentelemetry/version.h" @@ -24,6 +25,31 @@ class Tracer; /** * A Span represents a single operation within a Trace. + * + * Span attributes can be provided: + * - at span creation time, using Tracer::StartSpan(), + * - during the span lifetime, using Span::SetAttribute() + * + * Please note that head samplers, + * in the SDK (@ref opentelemetry::sdk::trace::Sampler), + * can only make sampling decisions based on data known + * at span creation time. + * + * When attributes are known early, adding attributes + * with @ref opentelemetry::trace::Tracer::StartSpan() is preferable. + * + * Attributes added or changed with Span::SetAttribute() + * can not change a sampler decision. + * + * Likewise, links can be provided: + * - at span creation time, using Tracer::StartSpan(), + * - during the span lifetime, using Span::AddLink() or Span::AddLinks(). + * + * When links are known early, adding links + * with @ref opentelemetry::trace::Tracer::StartSpan() is preferable. + * + * Links added with Span::AddLink() or Span::AddLinks() + * can not change a sampler decision. */ class Span { @@ -41,9 +67,14 @@ class Span Span &operator=(const Span &) = delete; Span &operator=(Span &&) = delete; - // Sets an attribute on the Span. If the Span previously contained a mapping - // for - // the key, the old value is replaced. + /** + * Sets an attribute on the Span (ABI). + * + * If the Span previously contained a mapping for the key, + * the old value is replaced. + * + * See comments about sampling in @ref opentelemetry::trace::Span + */ virtual void SetAttribute(nostd::string_view key, const common::AttributeValue &value) noexcept = 0; @@ -99,6 +130,106 @@ class Span attributes.begin(), attributes.end()}); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + + /** + * Add link (ABI). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + virtual void AddLink(const SpanContext &target, + const common::KeyValueIterable &attrs) noexcept = 0; + + /** + * Add links (ABI). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + virtual void AddLinks(const SpanContextKeyValueIterable &links) noexcept = 0; + + /** + * Add link (API helper). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + template ::value> * = nullptr> + void AddLink(const SpanContext &target, const U &attrs) + { + common::KeyValueIterableView view(attrs); + this->AddLink(target, view); + } + + /** + * Add link (API helper). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + void AddLink(const SpanContext &target, + std::initializer_list> attrs) + { + /* Build a container from std::initializer_list. */ + nostd::span> container{ + attrs.begin(), attrs.end()}; + + /* Build a view on the container. */ + common::KeyValueIterableView< + nostd::span>> + view(container); + + return this->AddLink(target, view); + } + + /** + * Add links (API helper). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + template ::value> * = nullptr> + void AddLinks(const U &links) + { + SpanContextKeyValueIterableView view(links); + this->AddLinks(view); + } + + /** + * Add links (API helper). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + void AddLinks( + std::initializer_list< + std::pair>>> + links) + { + /* Build a container from std::initializer_list. */ + nostd::span>>> + container{links.begin(), links.end()}; + + /* Build a view on the container. */ + SpanContextKeyValueIterableView>>>> + view(container); + + return this->AddLinks(view); + } + +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + // Sets the status of the span. The default status is Unset. Only the value of // the last call will be // recorded, and implementations are free to ignore previous calls. diff --git a/api/include/opentelemetry/trace/span_context_kv_iterable.h b/api/include/opentelemetry/trace/span_context_kv_iterable.h index 8f3010ce9d..aed3474272 100644 --- a/api/include/opentelemetry/trace/span_context_kv_iterable.h +++ b/api/include/opentelemetry/trace/span_context_kv_iterable.h @@ -6,6 +6,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/api/include/opentelemetry/trace/tracer_provider.h b/api/include/opentelemetry/trace/tracer_provider.h index bc8ff8da89..059298d395 100644 --- a/api/include/opentelemetry/trace/tracer_provider.h +++ b/api/include/opentelemetry/trace/tracer_provider.h @@ -3,6 +3,8 @@ #pragma once +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" @@ -20,15 +22,106 @@ class OPENTELEMETRY_EXPORT TracerProvider { public: virtual ~TracerProvider() = default; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + + /** + * Gets or creates a named Tracer instance (ABI). + * + * @since ABI_VERSION 2 + * + * @param[in] name Tracer instrumentation scope + * @param[in] version Instrumentation scope version + * @param[in] schema_url Instrumentation scope schema URL + * @param[in] attributes Instrumentation scope attributes (optional, may be nullptr) + */ + virtual nostd::shared_ptr GetTracer( + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const common::KeyValueIterable *attributes) noexcept = 0; + + /** + * Gets or creates a named Tracer instance (API helper). + * + * @since ABI_VERSION 2 + * + * @param[in] name Tracer instrumentation scope + * @param[in] version Instrumentation scope version, optional + * @param[in] schema_url Instrumentation scope schema URL, optional + */ + nostd::shared_ptr GetTracer(nostd::string_view name, + nostd::string_view version = "", + nostd::string_view schema_url = "") + { + return GetTracer(name, version, schema_url, nullptr); + } + + /** + * Gets or creates a named Tracer instance (API helper). + * + * @since ABI_VERSION 2 + * + * @param[in] name Tracer instrumentation scope + * @param[in] version Instrumentation scope version + * @param[in] schema_url Instrumentation scope schema URL + * @param[in] attributes Instrumentation scope attributes + */ + nostd::shared_ptr GetTracer( + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + std::initializer_list> attributes) + { + /* Build a container from std::initializer_list. */ + nostd::span> attributes_span{ + attributes.begin(), attributes.end()}; + + /* Build a view on the container. */ + common::KeyValueIterableView< + nostd::span>> + iterable_attributes{attributes_span}; + + /* Add attributes using the view. */ + return GetTracer(name, version, schema_url, &iterable_attributes); + } + + /** + * Gets or creates a named Tracer instance (API helper). + * + * @since ABI_VERSION 2 + * + * @param[in] name Tracer instrumentation scope + * @param[in] version Instrumentation scope version + * @param[in] schema_url Instrumentation scope schema URL + * @param[in] attributes Instrumentation scope attributes container + */ + template ::value> * = nullptr> + nostd::shared_ptr GetTracer(nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const T &attributes) + { + /* Build a view on the container. */ + common::KeyValueIterableView iterable_attributes(attributes); + + /* Add attributes using the view. */ + return GetTracer(name, version, schema_url, &iterable_attributes); + } + +#else + /** * Gets or creates a named tracer instance. * * Optionally a version can be passed to create a named and versioned tracer * instance. */ - virtual nostd::shared_ptr GetTracer(nostd::string_view library_name, - nostd::string_view library_version = "", - nostd::string_view schema_url = "") noexcept = 0; + virtual nostd::shared_ptr GetTracer(nostd::string_view name, + nostd::string_view version = "", + nostd::string_view schema_url = "") noexcept = 0; +#endif }; } // namespace trace OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index fd88ffb383..79284c1501 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -10,9 +10,9 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.11.0" +#define OPENTELEMETRY_VERSION "1.12.0" #define OPENTELEMETRY_VERSION_MAJOR 1 -#define OPENTELEMETRY_VERSION_MINOR 11 +#define OPENTELEMETRY_VERSION_MINOR 12 #define OPENTELEMETRY_VERSION_PATCH 0 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/api/test/context/runtime_context_test.cc b/api/test/context/runtime_context_test.cc index e85fc6350d..40b11dde95 100644 --- a/api/test/context/runtime_context_test.cc +++ b/api/test/context/runtime_context_test.cc @@ -4,6 +4,9 @@ #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/context/context.h" +#include +#include + #include using namespace opentelemetry; diff --git a/api/test/singleton/singleton_test.cc b/api/test/singleton/singleton_test.cc index 44a445e5bd..187e26f2b4 100644 --- a/api/test/singleton/singleton_test.cc +++ b/api/test/singleton/singleton_test.cc @@ -264,13 +264,25 @@ class MyTracerProvider : public trace::TracerProvider return result; } - nostd::shared_ptr GetTracer(nostd::string_view /* library_name */, - nostd::string_view /* library_version */, +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::shared_ptr GetTracer( + nostd::string_view /* name */, + nostd::string_view /* version */, + nostd::string_view /* schema_url */, + const common::KeyValueIterable * /* attributes */) noexcept override + { + nostd::shared_ptr result(new MyTracer()); + return result; + } +#else + nostd::shared_ptr GetTracer(nostd::string_view /* name */, + nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override { nostd::shared_ptr result(new MyTracer()); return result; } +#endif }; void setup_otel() diff --git a/api/test/trace/noop_test.cc b/api/test/trace/noop_test.cc index 130496faf0..b47700d442 100644 --- a/api/test/trace/noop_test.cc +++ b/api/test/trace/noop_test.cc @@ -46,6 +46,21 @@ TEST(NoopTest, UseNoopTracers) s1->GetContext(); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +TEST(NoopTest, UseNoopTracersAbiv2) +{ + std::shared_ptr tracer{new trace_api::NoopTracer{}}; + auto s1 = tracer->StartSpan("abc"); + + EXPECT_EQ(s1->IsRecording(), false); + + trace_api::SpanContext target(false, false); + s1->AddLink(target, {{"noop1", 1}}); + + s1->AddLinks({{trace_api::SpanContext(false, false), {{"noop2", 2}}}}); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ + TEST(NoopTest, StartSpan) { std::shared_ptr tracer{new trace_api::NoopTracer{}}; diff --git a/api/test/trace/provider_test.cc b/api/test/trace/provider_test.cc index 21e3619334..be2ca2842c 100644 --- a/api/test/trace/provider_test.cc +++ b/api/test/trace/provider_test.cc @@ -3,6 +3,7 @@ #include "opentelemetry/trace/provider.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/trace/tracer_provider.h" #include @@ -14,12 +15,24 @@ namespace nostd = opentelemetry::nostd; class TestProvider : public TracerProvider { - nostd::shared_ptr GetTracer(nostd::string_view /* library_name */, - nostd::string_view /* library_version */, + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::shared_ptr GetTracer( + nostd::string_view /* name */, + nostd::string_view /* version */, + nostd::string_view /* schema_url */, + const opentelemetry::common::KeyValueIterable * /* attributes */) noexcept override + { + return nostd::shared_ptr(nullptr); + } +#else + nostd::shared_ptr GetTracer(nostd::string_view /* name */, + nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override { return nostd::shared_ptr(nullptr); } +#endif }; TEST(Provider, GetTracerProviderDefault) diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index 2a6634baa4..daa5131dc5 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -18,10 +18,10 @@ ROOT_DIR="${SCRIPT_DIR}/../../" # https://github.com/open-telemetry/opentelemetry-specification # Repository from 1.21.0: # https://github.com/open-telemetry/semantic-conventions -SEMCONV_VERSION=1.21.0 +SEMCONV_VERSION=1.22.0 # repository: https://github.com/open-telemetry/build-tools -GENERATOR_VERSION=0.19.0 +GENERATOR_VERSION=0.22.0 SPEC_VERSION=v$SEMCONV_VERSION SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index e55cf8e536..b97617e96f 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -58,7 +58,7 @@ switch ($action) { cmake $SRC_DIR ` -DVCPKG_TARGET_TRIPLET=x64-windows ` -DOPENTELEMETRY_BUILD_DLL=1 ` - "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" + "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE if ($exit -ne 0) { exit $exit @@ -79,6 +79,16 @@ switch ($action) { if ($exit -ne 0) { exit $exit } + examples\metrics_simple\Debug\metrics_ostream_example.exe + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + examples\logs_simple\Debug\example_logs_simple.exe + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } } "cmake.maintainer.test" { cd "$BUILD_DIR" diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 948a62b9dd..d9dc0c178f 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -112,7 +112,6 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_HTTP_SSL_PREVIEW=ON \ -DWITH_OTLP_HTTP_SSL_TLS_PREVIEW=ON \ - -DWITH_REMOVE_METER_PREVIEW=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ @@ -135,7 +134,6 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_HTTP_SSL_PREVIEW=ON \ -DWITH_OTLP_HTTP_SSL_TLS_PREVIEW=ON \ - -DWITH_REMOVE_METER_PREVIEW=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ @@ -159,7 +157,6 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_HTTP_SSL_PREVIEW=ON \ -DWITH_OTLP_HTTP_SSL_TLS_PREVIEW=ON \ - -DWITH_REMOVE_METER_PREVIEW=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ @@ -181,7 +178,6 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_HTTP_SSL_PREVIEW=ON \ -DWITH_OTLP_HTTP_SSL_TLS_PREVIEW=ON \ - -DWITH_REMOVE_METER_PREVIEW=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ diff --git a/cmake/package.cmake b/cmake/package.cmake index ef0a879e0f..c14b38fde0 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -1,6 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +set(CPACK_PACKAGE_VERSION "${OPENTELEMETRY_VERSION}") set(CPACK_PACKAGE_DESCRIPTION "OpenTelemetry C++ for Linux") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenTelemetry C++ for Linux - C++ Implementation of OpenTelemetry Specification") set(CPACK_PACKAGE_VENDOR "OpenTelemetry") diff --git a/cmake/patch-imported-config.cmake b/cmake/patch-imported-config.cmake new file mode 100644 index 0000000000..ec68d74099 --- /dev/null +++ b/cmake/patch-imported-config.cmake @@ -0,0 +1,141 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# Some prebuilt or installed targets may have different CONFIG settings than +# what we use to configure otel-cpp. This file applies patches to the imported +# targets in order to use compatible CONFIG settings for fallback. + +# Common dependencies +project_build_tools_patch_default_imported_config(ZLIB::ZLIB) + +# protobuf targets +if(Protobuf_FOUND OR PROTOBUF_FOUND) + project_build_tools_patch_default_imported_config( + utf8_range::utf8_range utf8_range::utf8_validity protobuf::libprotobuf-lite + protobuf::libprotobuf protobuf::libprotoc) +endif() + +# cares targets +if(TARGET c-ares::cares) + project_build_tools_patch_default_imported_config(c-ares::cares) +endif() + +# curl targets +if(TARGET CURL::libcurl) + project_build_tools_patch_default_imported_config(CURL::libcurl) +endif() + +# abseil targets +if(WITH_ABSEIL) + project_build_tools_patch_default_imported_config( + absl::bad_variant_access + absl::raw_logging_internal + absl::log_severity + absl::log_internal_check_op + absl::log_internal_nullguard + absl::strings + absl::strings_internal + absl::base + absl::spinlock_wait + absl::int128 + absl::throw_delegate + absl::log_internal_message + absl::examine_stack + absl::stacktrace + absl::debugging_internal + absl::symbolize + absl::demangle_internal + absl::malloc_internal + absl::log_internal_format + absl::log_internal_globals + absl::time + absl::civil_time + absl::time_zone + absl::str_format_internal + absl::log_internal_proto + absl::log_internal_log_sink_set + absl::log_globals + absl::hash + absl::city + absl::bad_optional_access + absl::low_level_hash + absl::log_entry + absl::log_sink + absl::synchronization + absl::graphcycles_internal + absl::strerror + absl::log_internal_conditions + absl::cord + absl::cord_internal + absl::crc_cord_state + absl::crc32c + absl::crc_cpu_detect + absl::crc_internal + absl::cordz_functions + absl::exponential_biased + absl::cordz_info + absl::cordz_handle + absl::leak_check + absl::die_if_null + absl::flags + absl::flags_commandlineflag + absl::flags_commandlineflag_internal + absl::flags_config + absl::flags_program_name + absl::flags_internal + absl::flags_marshalling + absl::flags_reflection + absl::flags_private_handle_accessor + absl::raw_hash_set + absl::hashtablez_sampler + absl::log_initialize + absl::status + absl::statusor) +endif() + +# gRPC targets +if(TARGET gRPC::grpc++) + project_build_tools_patch_default_imported_config( + gRPC::cares + gRPC::re2 + gRPC::ssl + gRPC::crypto + gRPC::zlibstatic + gRPC::address_sorting + gRPC::gpr + gRPC::grpc + gRPC::grpc_unsecure + gRPC::grpc++ + gRPC::grpc++_alts + gRPC::grpc++_error_details + gRPC::grpc++_reflection + gRPC::grpc++_unsecure + gRPC::grpc_authorization_provider + gRPC::grpc_plugin_support + gRPC::grpcpp_channelz + gRPC::upb) +endif() + +# prometheus targets +if(TARGET prometheus-cpp::core) + project_build_tools_patch_default_imported_config( + prometheus-cpp::core prometheus-cpp::pull prometheus-cpp::push) +endif() + +# civetweb targets +if(TARGET civetweb::civetweb) + project_build_tools_patch_default_imported_config( + civetweb::civetweb civetweb::server civetweb::civetweb-cpp) +endif() + +if(BUILD_TESTING) + project_build_tools_patch_default_imported_config( + GTest::gtest + GTest::gtest_main + GTest::gmock + GTest::gmock_main + GTest::GTest + GTest::Main + benchmark::benchmark + benchmark::benchmark_main) +endif() diff --git a/cmake/tools.cmake b/cmake/tools.cmake index 345fc88ff7..ee191121ca 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -117,3 +117,83 @@ function(project_build_tools_get_imported_location OUTPUT_VAR_NAME TARGET_NAME) PARENT_SCOPE) endif() endfunction() + +#[[ +If we build third party packages with a different CONFIG setting from building +otel-cpp, cmake may not find a suitable file in imported targets (#705, #1359) +when linking. But on some platforms, different CONFIG settings can be used when +these CONFIG settings have the same ABI. For example, on Linux, we can build +gRPC and protobuf with -DCMAKE_BUILD_TYPE=Release, but build otel-cpp with +-DCMAKE_BUILD_TYPE=Debug and link these libraries together. +The properties of imported targets can be found here: +https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets +]] +function(project_build_tools_patch_default_imported_config) + set(PATCH_VARS + IMPORTED_IMPLIB + IMPORTED_LIBNAME + IMPORTED_LINK_DEPENDENT_LIBRARIES + IMPORTED_LINK_INTERFACE_LANGUAGES + IMPORTED_LINK_INTERFACE_LIBRARIES + IMPORTED_LINK_INTERFACE_MULTIPLICITY + IMPORTED_LOCATION + IMPORTED_NO_SONAME + IMPORTED_OBJECTS + IMPORTED_SONAME) + foreach(TARGET_NAME ${ARGN}) + if(TARGET ${TARGET_NAME}) + get_target_property(IS_IMPORTED_TARGET ${TARGET_NAME} IMPORTED) + if(NOT IS_IMPORTED_TARGET) + continue() + endif() + + if(CMAKE_VERSION VERSION_LESS "3.19.0") + get_target_property(TARGET_TYPE_NAME ${TARGET_NAME} TYPE) + if(TARGET_TYPE_NAME STREQUAL "INTERFACE_LIBRARY") + continue() + endif() + endif() + + get_target_property(DO_NOT_OVERWRITE ${TARGET_NAME} IMPORTED_LOCATION) + if(DO_NOT_OVERWRITE) + continue() + endif() + + # MSVC's STL and debug level must match the target, so we can only move + # out IMPORTED_LOCATION_NOCONFIG + if(MSVC) + set(PATCH_IMPORTED_CONFIGURATION "NOCONFIG") + else() + get_target_property(PATCH_IMPORTED_CONFIGURATION ${TARGET_NAME} + IMPORTED_CONFIGURATIONS) + endif() + + if(NOT PATCH_IMPORTED_CONFIGURATION) + continue() + endif() + + get_target_property(PATCH_TARGET_LOCATION ${TARGET_NAME} + "IMPORTED_LOCATION_${PATCH_IMPORTED_CONFIGURATION}") + if(NOT PATCH_TARGET_LOCATION) + continue() + endif() + + foreach(PATCH_IMPORTED_KEY IN LISTS PATCH_VARS) + get_target_property( + PATCH_IMPORTED_VALUE ${TARGET_NAME} + "${PATCH_IMPORTED_KEY}_${PATCH_IMPORTED_CONFIGURATION}") + if(PATCH_IMPORTED_VALUE) + set_target_properties( + ${TARGET_NAME} PROPERTIES "${PATCH_IMPORTED_KEY}" + "${PATCH_IMPORTED_VALUE}") + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + message( + STATUS + "Patch: ${TARGET_NAME} ${PATCH_IMPORTED_KEY} will use ${PATCH_IMPORTED_KEY}_${PATCH_IMPORTED_CONFIGURATION}(\"${PATCH_IMPORTED_VALUE}\") by default." + ) + endif() + endif() + endforeach() + endif() + endforeach() +endfunction() diff --git a/docs/public/conf.py b/docs/public/conf.py index 1c090b8b35..2375c45924 100644 --- a/docs/public/conf.py +++ b/docs/public/conf.py @@ -24,7 +24,7 @@ author = 'OpenTelemetry authors' # The full version, including alpha/beta/rc tags -release = "1.11.0" +release = "1.12.0" # Run sphinx on subprojects and copy output # ----------------------------------------- diff --git a/examples/common/metrics_foo_library/CMakeLists.txt b/examples/common/metrics_foo_library/CMakeLists.txt index a91b2595b8..abda93c3e6 100644 --- a/examples/common/metrics_foo_library/CMakeLists.txt +++ b/examples/common/metrics_foo_library/CMakeLists.txt @@ -1,6 +1,12 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +if(DEFINED OPENTELEMETRY_BUILD_DLL) + add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL) +endif() + add_library(common_metrics_foo_library foo_library.h foo_library.cc) set_target_version(common_metrics_foo_library) -target_link_libraries(common_metrics_foo_library PUBLIC opentelemetry_api) + +target_link_libraries(common_metrics_foo_library + PUBLIC ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) diff --git a/examples/grpc/client.cc b/examples/grpc/client.cc index 92088c12f6..3163b38986 100644 --- a/examples/grpc/client.cc +++ b/examples/grpc/client.cc @@ -53,8 +53,8 @@ class GreeterClient {{SemanticConventions::kRpcSystem, "grpc"}, {SemanticConventions::kRpcService, "grpc-example.GreetService"}, {SemanticConventions::kRpcMethod, "Greet"}, - {SemanticConventions::kServerSocketAddress, ip}, - {SemanticConventions::kServerPort, port}}, + {SemanticConventions::kNetworkPeerAddress, ip}, + {SemanticConventions::kNetworkPeerPort, port}}, options); auto scope = get_tracer("grpc-client")->WithActiveSpan(span); diff --git a/examples/metrics_simple/CMakeLists.txt b/examples/metrics_simple/CMakeLists.txt index 2018ed808c..0fc8c24621 100644 --- a/examples/metrics_simple/CMakeLists.txt +++ b/examples/metrics_simple/CMakeLists.txt @@ -1,9 +1,20 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +if(DEFINED OPENTELEMETRY_BUILD_DLL) + add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL) +endif() + include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include) + add_executable(metrics_ostream_example metrics_ostream.cc) -target_link_libraries( - metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics - opentelemetry_exporter_ostream_metrics opentelemetry_resources - common_metrics_foo_library) +target_link_libraries(metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + +if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(metrics_ostream_example opentelemetry_cpp) +else() + target_link_libraries( + metrics_ostream_example opentelemetry_metrics + opentelemetry_exporter_ostream_metrics opentelemetry_resources) +endif() diff --git a/examples/otlp/CMakeLists.txt b/examples/otlp/CMakeLists.txt index 398300ab36..5d051a52cc 100644 --- a/examples/otlp/CMakeLists.txt +++ b/examples/otlp/CMakeLists.txt @@ -28,10 +28,15 @@ if(WITH_OTLP_GRPC) add_executable(example_otlp_grpc_metric grpc_metric_main.cc) - target_link_libraries( - example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT} - common_metrics_foo_library opentelemetry_metrics - opentelemetry_exporter_otlp_grpc_metrics) + target_link_libraries(example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + + if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(example_otlp_grpc_metric opentelemetry_cpp) + else() + target_link_libraries(example_otlp_grpc_metric opentelemetry_metrics + opentelemetry_exporter_otlp_grpc_metrics) + endif() # LOG @@ -66,10 +71,17 @@ if(WITH_OTLP_HTTP) # METRIC add_executable(example_otlp_http_metric http_metric_main.cc) - target_link_libraries( - example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT} - common_metrics_foo_library opentelemetry_metrics - opentelemetry_exporter_otlp_http_metric) + target_link_libraries(example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + + if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(example_otlp_http_metric opentelemetry_cpp + opentelemetry_common) + else() + target_link_libraries( + example_otlp_http_metric common_metrics_foo_library opentelemetry_metrics + opentelemetry_exporter_otlp_http_metric) + endif() # LOG diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 55de64438d..14d1a746df 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -49,6 +49,14 @@ class Span final : public trace::Span const common::KeyValueIterable & /*attributes*/) noexcept override {} +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const trace::SpanContext & /* target */, + const common::KeyValueIterable & /* attrs */) noexcept override + {} + + void AddLinks(const trace::SpanContextKeyValueIterable & /* links */) noexcept override {} +#endif + void SetStatus(trace::StatusCode /*code*/, nostd::string_view /*description*/) noexcept override {} diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h index baa4e860b1..05c8a89982 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h @@ -55,7 +55,7 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter mutable opentelemetry::common::SpinLockMutex lock_; bool isShutdown() const noexcept; - // Mapping status number to the string from api/include/opentelemetry/trace/canonical_code.h + // Mapping status number to the string from api/include/opentelemetry/trace/span_metadata.h std::map statusMap{{0, "Unset"}, {1, "Ok"}, {2, "Error"}}; // various print helpers diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h index d605100ae6..f8b3ee1fc3 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h @@ -15,7 +15,7 @@ namespace otlp /** * Factory class for OtlpGrpcMetricExporter. */ -class OtlpGrpcMetricExporterFactory +class OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterFactory { public: /** diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h index 2fe0476575..7fa7980470 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h @@ -17,7 +17,7 @@ namespace otlp /** * Factory class for OtlpHttpMetricExporter. */ -class OtlpHttpMetricExporterFactory +class OPENTELEMETRY_EXPORT OtlpHttpMetricExporterFactory { public: /** diff --git a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h index fdc244255b..bd1f716ad8 100644 --- a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h +++ b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h @@ -12,7 +12,6 @@ #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/trace/canonical_code.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/trace_id.h" diff --git a/ext/include/opentelemetry/ext/zpages/tracez_data.h b/ext/include/opentelemetry/ext/zpages/tracez_data.h index 4594fbe057..5f36a6b047 100644 --- a/ext/include/opentelemetry/ext/zpages/tracez_data.h +++ b/ext/include/opentelemetry/ext/zpages/tracez_data.h @@ -12,13 +12,11 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/trace/canonical_code.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" using opentelemetry::ext::zpages::ThreadsafeSpanData; -using opentelemetry::trace::CanonicalCode; using opentelemetry::trace::SpanId; using opentelemetry::trace::TraceId; diff --git a/ext/include/opentelemetry/ext/zpages/tracez_data_aggregator.h b/ext/include/opentelemetry/ext/zpages/tracez_data_aggregator.h index 62c944b704..5bc7e847db 100644 --- a/ext/include/opentelemetry/ext/zpages/tracez_data_aggregator.h +++ b/ext/include/opentelemetry/ext/zpages/tracez_data_aggregator.h @@ -19,9 +19,6 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/trace/canonical_code.h" - -using opentelemetry::trace::CanonicalCode; OPENTELEMETRY_BEGIN_NAMESPACE namespace ext diff --git a/ext/src/dll/CMakeLists.txt b/ext/src/dll/CMakeLists.txt index c0b6b91745..687d55e01f 100644 --- a/ext/src/dll/CMakeLists.txt +++ b/ext/src/dll/CMakeLists.txt @@ -22,6 +22,20 @@ if(WITH_OTLP_HTTP) PRIVATE opentelemetry_exporter_otlp_http) endif() +target_link_libraries( + opentelemetry_cpp PRIVATE opentelemetry_metrics + opentelemetry_exporter_ostream_metrics) + +if(WITH_OTLP_GRPC) + target_link_libraries(opentelemetry_cpp + PRIVATE opentelemetry_exporter_otlp_grpc_metrics) +endif() + +if(WITH_OTLP_HTTP) + target_link_libraries(opentelemetry_cpp + PRIVATE opentelemetry_exporter_otlp_http_metric) +endif() + target_link_libraries( opentelemetry_cpp PRIVATE opentelemetry_logs opentelemetry_exporter_ostream_logs) diff --git a/ext/src/dll/opentelemetry_cpp.src b/ext/src/dll/opentelemetry_cpp.src index 5d6d5e0092..10172dbb3f 100644 --- a/ext/src/dll/opentelemetry_cpp.src +++ b/ext/src/dll/opentelemetry_cpp.src @@ -57,15 +57,46 @@ EXPORTS ?ForceFlush@TracerProvider@trace@sdk@v1@opentelemetry@@QEAA_NV?$duration@_JU?$ratio@$00$0PECEA@@std@@@chrono@std@@@Z ?ForceFlush@LoggerProvider@logs@sdk@v1@opentelemetry@@QEAA_NV?$duration@_JU?$ratio@$00$0PECEA@@std@@@chrono@std@@@Z ??0OStreamLogRecordExporter@logs@exporter@v1@opentelemetry@@QEAA@AEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z + + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::metrics::OStreamMetricExporterFactory::Create(void) + ?Create@OStreamMetricExporterFactory@metrics@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::PeriodicExportingMetricReaderFactory::Create(class std::unique_ptr >,struct opentelemetry::v1::sdk::metrics::PeriodicExportingMetricReaderOptions const & __ptr64) + ?Create@PeriodicExportingMetricReaderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@7@AEBUPeriodicExportingMetricReaderOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterProviderFactory::Create(void) + ?Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterProvider@metrics@v1@opentelemetry@@U?$default_delete@VMeterProvider@metrics@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterContextFactory::Create(void) + ?Create@MeterContextFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterContext@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterContext@metrics@sdk@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterProviderFactory::Create(class std::unique_ptr >) + ?Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterProvider@metrics@v1@opentelemetry@@U?$default_delete@VMeterProvider@metrics@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterContext@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterContext@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::ViewFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,enum opentelemetry::v1::sdk::metrics::AggregationType,class std::shared_ptr) + ?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@V?$shared_ptr@VAggregationConfig@metrics@sdk@v1@opentelemetry@@@7@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::ViewFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,enum opentelemetry::v1::sdk::metrics::AggregationType) + ?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterSelectorFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &) + ?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::InstrumentSelectorFactory::Create(enum opentelemetry::v1::sdk::metrics::InstrumentType,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &) + ?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@W4InstrumentType@2345@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@1@Z + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterContext::AddMetricReader(class std::shared_ptr) + ?AddMetricReader@MeterContext@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddMetricReader(class std::shared_ptr) + ?AddMetricReader@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddView(class std::unique_ptr >,class std::unique_ptr >,class std::unique_ptr >) + ?AddView@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@7@V?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z + #if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) ?GetOtlpDefaultTracesTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultTracesHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ ?GetOtlpDefaultLogsTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultLogsHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ + ?GetOtlpDefaultMetricsTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ + ?GetOtlpDefaultMetricsHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ #endif // defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) #if defined(WITH_OTLP_GRPC) // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions const & __ptr64) ?Create@OtlpGrpcLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcExporterOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterOptions const & __ptr64) + ?Create@OtlpGrpcMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcMetricExporterOptions@2345@@Z + ?GetOtlpDefaultGrpcTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultGrpcTracesIsInsecure@otlp@exporter@v1@opentelemetry@@YA_NXZ ?GetOtlpDefaultTracesSslCertificatePath@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @@ -76,5 +107,9 @@ EXPORTS ?Create@OtlpHttpLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpLogRecordExporterOptions@2345@@Z ?GetOtlpDefaultHttpTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultHttpLogsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterOptions const &) + ?Create@OtlpHttpMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpMetricExporterOptions@2345@@Z + ?GetOtlpDefaultHttpMetricsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ #endif // defined(WITH_OTLP_HTTP) // clang-format on diff --git a/opentracing-shim/src/tracer_shim.cc b/opentracing-shim/src/tracer_shim.cc index c8805d15ef..41c6404624 100644 --- a/opentracing-shim/src/tracer_shim.cc +++ b/opentracing-shim/src/tracer_shim.cc @@ -148,13 +148,20 @@ opentracing::expected> TracerShim::ext auto span_context = opentelemetry::trace::GetSpan(context)->GetContext(); auto baggage = opentelemetry::baggage::GetBaggage(context); - // If the extracted SpanContext is invalid AND the extracted Baggage is empty, - // this operation MUST return a null value, and otherwise it MUST return a - // SpanContext Shim instance with the extracted values. - SpanContextShim *context_shim = (!span_context.IsValid() && utils::isBaggageEmpty(baggage)) - ? nullptr - : new (std::nothrow) SpanContextShim(span_context, baggage); - + // The operation MUST return a `SpanContext` Shim instance with the extracted values if any of + // these conditions are met: + // * `SpanContext` is valid. + // * `SpanContext` is sampled. + // * `SpanContext` contains non-empty extracted `Baggage`. + // Otherwise, the operation MUST return null or empty value. + SpanContextShim *context_shim = + (!span_context.IsValid() && !span_context.IsSampled() && utils::isBaggageEmpty(baggage)) + ? nullptr + : new (std::nothrow) SpanContextShim(span_context, baggage); + + // Note: Invalid but sampled `SpanContext` instances are returned as a way to support + // jaeger-debug-id headers (https://github.com/jaegertracing/jaeger-client-java#via-http-headers) + // which are used to force propagation of debug information. return opentracing::make_expected(std::unique_ptr(context_shim)); } diff --git a/opentracing-shim/test/tracer_shim_test.cc b/opentracing-shim/test/tracer_shim_test.cc index 7a06175323..9d57bbcae4 100644 --- a/opentracing-shim/test/tracer_shim_test.cc +++ b/opentracing-shim/test/tracer_shim_test.cc @@ -211,6 +211,7 @@ TEST_F(TracerShimTest, ExtractOnlyBaggage) auto span_context_shim = static_cast(span_context.value().get()); ASSERT_TRUE(span_context_shim != nullptr); ASSERT_FALSE(span_context_shim->context().IsValid()); + ASSERT_FALSE(span_context_shim->context().IsSampled()); ASSERT_FALSE(shim::utils::isBaggageEmpty(span_context_shim->baggage())); std::string value; diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h b/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h index 6ae111fd85..4f3346707f 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h @@ -35,7 +35,8 @@ class DefaultAggregation case AggregationType::kSum: return (instrument_descriptor.value_type_ == InstrumentValueType::kLong) ? std::move(std::unique_ptr(new LongSumAggregation(is_monotonic))) - : std::move(std::unique_ptr(new DoubleSumAggregation(true))); + : std::move( + std::unique_ptr(new DoubleSumAggregation(is_monotonic))); break; case AggregationType::kHistogram: { if (instrument_descriptor.value_type_ == InstrumentValueType::kLong) diff --git a/sdk/include/opentelemetry/sdk/metrics/async_instruments.h b/sdk/include/opentelemetry/sdk/metrics/async_instruments.h index a22ce1f0f8..48c7d14ec5 100644 --- a/sdk/include/opentelemetry/sdk/metrics/async_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/async_instruments.h @@ -25,6 +25,7 @@ class ObservableInstrument : public opentelemetry::metrics::ObservableInstrument ObservableInstrument(InstrumentDescriptor instrument_descriptor, std::unique_ptr storage, std::shared_ptr observable_registry); + ~ObservableInstrument() override; void AddCallback(opentelemetry::metrics::ObservableCallbackPtr callback, void *state) noexcept override; diff --git a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h index c4254793f3..1c5c1a0d7b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h @@ -16,7 +16,7 @@ namespace metrics class MetricReader; class PushMetricExporter; -class PeriodicExportingMetricReaderFactory +class OPENTELEMETRY_EXPORT PeriodicExportingMetricReaderFactory { public: static std::unique_ptr Create(std::unique_ptr exporter, diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h index d5ca16cc27..13e3a9f290 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h @@ -21,7 +21,7 @@ class ViewRegistry; /** * Factory class for MeterContext. */ -class MeterContextFactory +class OPENTELEMETRY_EXPORT MeterContextFactory { public: /** diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index 00f9a35ac2..8a8c04c636 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -30,7 +30,7 @@ class MeterContext; class MetricCollector; class MetricReader; -class MeterProvider final : public opentelemetry::metrics::MeterProvider +class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics::MeterProvider { public: /** @@ -66,7 +66,7 @@ class MeterProvider final : public opentelemetry::metrics::MeterProvider nostd::string_view schema_url = "") noexcept override; #endif -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 void RemoveMeter(nostd::string_view name, nostd::string_view version, nostd::string_view schema_url) noexcept override; diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index 6c0375ad9d..69e77ebf5e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -56,7 +56,7 @@ namespace metrics even if this forces, temporarily, existing applications to use a downcast. */ -class MeterProviderFactory +class OPENTELEMETRY_EXPORT MeterProviderFactory { public: static std::unique_ptr Create(); diff --git a/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h b/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h index 5eb5b6d6ff..b584cc055f 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h @@ -35,6 +35,8 @@ class ObservableRegistry void *state, opentelemetry::metrics::ObservableInstrument *instrument); + void CleanupCallback(opentelemetry::metrics::ObservableInstrument *instrument); + void Observe(opentelemetry::common::SystemTimestamp collection_ts); private: diff --git a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h index 67c8592bb6..690a9168d0 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h @@ -4,8 +4,8 @@ #pragma once #include +#include -#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/view/predicate_factory.h" #include "opentelemetry/version.h" @@ -19,8 +19,8 @@ class InstrumentSelector { public: InstrumentSelector(opentelemetry::sdk::metrics::InstrumentType instrument_type, - opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view units) + const std::string &name, + const std::string &units) : name_filter_{PredicateFactory::GetPredicate(name, PredicateType::kPattern)}, unit_filter_{PredicateFactory::GetPredicate(units, PredicateType::kExact)}, instrument_type_{instrument_type} diff --git a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h index f30b1e27c1..3c221f123b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h @@ -3,7 +3,8 @@ #pragma once -#include "opentelemetry/nostd/string_view.h" +#include + #include "opentelemetry/sdk/metrics/instruments.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,13 +15,13 @@ namespace metrics class InstrumentSelector; -class InstrumentSelectorFactory +class OPENTELEMETRY_EXPORT InstrumentSelectorFactory { public: static std::unique_ptr Create( opentelemetry::sdk::metrics::InstrumentType instrument_type, - opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view unit); + const std::string &name, + const std::string &unit); }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h index 16d777b71f..65dba7d7b9 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h @@ -4,8 +4,8 @@ #pragma once #include +#include -#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/metrics/view/predicate_factory.h" #include "opentelemetry/version.h" @@ -17,9 +17,7 @@ namespace metrics class MeterSelector { public: - MeterSelector(opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view version, - opentelemetry::nostd::string_view schema) + MeterSelector(const std::string &name, const std::string &version, const std::string &schema) : name_filter_{PredicateFactory::GetPredicate(name, PredicateType::kExact)}, version_filter_{PredicateFactory::GetPredicate(version, PredicateType::kExact)}, schema_filter_{PredicateFactory::GetPredicate(schema, PredicateType::kExact)} diff --git a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h index f335f725f7..47aa77b772 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h @@ -4,8 +4,8 @@ #pragma once #include +#include -#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -16,12 +16,12 @@ namespace metrics class MeterSelector; -class MeterSelectorFactory +class OPENTELEMETRY_EXPORT MeterSelectorFactory { public: - static std::unique_ptr Create(opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view version, - opentelemetry::nostd::string_view schema); + static std::unique_ptr Create(const std::string &name, + const std::string &version, + const std::string &schema); }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h index 9396a6c7f9..1b45f80c36 100644 --- a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h +++ b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h @@ -24,7 +24,14 @@ namespace SemanticConventions /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.21.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.22.0"; + +/** + * Uniquely identifies the framework API revision offered by a version ({@code os.version}) of the + * android operating system. More information can be found here. + */ +static constexpr const char *kAndroidOsApiLevel = "android.os.api_level"; /** * Array of brand name and version separated by a space @@ -36,6 +43,25 @@ static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.21 */ static constexpr const char *kBrowserBrands = "browser.brands"; +/** + * Preferred language of the user using the browser + * + *

Notes: +

  • This value is intended to be taken from the Navigator API {@code + navigator.language}.
+ */ +static constexpr const char *kBrowserLanguage = "browser.language"; + +/** + * A boolean that is true if the browser is running on a mobile device + * + *

Notes: +

  • This value is intended to be taken from the UA client hints API ({@code + navigator.userAgentData.mobile}). If unavailable, this attribute SHOULD be left unset.
+ */ +static constexpr const char *kBrowserMobile = "browser.mobile"; + /** * The platform on which the browser is running * @@ -54,34 +80,34 @@ provides. static constexpr const char *kBrowserPlatform = "browser.platform"; /** - * A boolean that is true if the browser is running on a mobile device + * The cloud account ID the resource is assigned to. + */ +static constexpr const char *kCloudAccountId = "cloud.account.id"; + +/** + * Cloud regions often have multiple, isolated locations known as zones to increase availability. + Availability zone represents the zone where the resource is running. * *

Notes: -

  • This value is intended to be taken from the UA client hints API ({@code - navigator.userAgentData.mobile}). If unavailable, this attribute SHOULD be left unset.
+
  • Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
  • +
*/ -static constexpr const char *kBrowserMobile = "browser.mobile"; +static constexpr const char *kCloudAvailabilityZone = "cloud.availability_zone"; /** - * Preferred language of the user using the browser + * The cloud platform in use. * *

Notes: -

  • This value is intended to be taken from the Navigator API {@code - navigator.language}.
+
  • The prefix of the service SHOULD match the one specified in {@code cloud.provider}.
  • +
*/ -static constexpr const char *kBrowserLanguage = "browser.language"; +static constexpr const char *kCloudPlatform = "cloud.platform"; /** * Name of the cloud provider. */ static constexpr const char *kCloudProvider = "cloud.provider"; -/** - * The cloud account ID the resource is assigned to. - */ -static constexpr const char *kCloudAccountId = "cloud.account.id"; - /** * The geographical region the resource is running. * @@ -127,23 +153,10 @@ that would usually share a TracerProvider. static constexpr const char *kCloudResourceId = "cloud.resource_id"; /** - * Cloud regions often have multiple, isolated locations known as zones to increase availability. - Availability zone represents the zone where the resource is running. - * - *

Notes: -

  • Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
  • -
- */ -static constexpr const char *kCloudAvailabilityZone = "cloud.availability_zone"; - -/** - * The cloud platform in use. - * - *

Notes: -

  • The prefix of the service SHOULD match the one specified in {@code cloud.provider}.
  • -
+ * The ARN of an ECS cluster. */ -static constexpr const char *kCloudPlatform = "cloud.platform"; +static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; /** * The Amazon Resource Name (ARN) of an ECS cluster. - */ -static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; - /** * The launch @@ -187,15 +194,6 @@ static constexpr const char *kAwsEcsTaskRevision = "aws.ecs.task.revision"; */ static constexpr const char *kAwsEksClusterArn = "aws.eks.cluster.arn"; -/** - * The name(s) of the AWS log group(s) an application is writing to. - * - *

Notes: -

  • 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.
- */ -static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; - /** * The Amazon Resource Name(s) (ARN) of the AWS log group(s). * @@ -207,9 +205,13 @@ static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; static constexpr const char *kAwsLogGroupArns = "aws.log.group.arns"; /** - * The name(s) of the AWS log stream(s) an application is writing to. + * The name(s) of the AWS log group(s) an application is writing to. + * + *

Notes: +

  • 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.
*/ -static constexpr const char *kAwsLogStreamNames = "aws.log.stream.names"; +static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; /** * The ARN(s) of the AWS log stream(s). @@ -222,6 +224,11 @@ static constexpr const char *kAwsLogStreamNames = "aws.log.stream.names"; */ static constexpr const char *kAwsLogStreamArns = "aws.log.stream.arns"; +/** + * The name(s) of the AWS log stream(s) an application is writing to. + */ +static constexpr const char *kAwsLogStreamNames = "aws.log.stream.names"; + /** * The name of the Cloud Run
execution being run for the @@ -238,6 +245,12 @@ static constexpr const char *kGcpCloudRunJobExecution = "gcp.cloud_run.job.execu */ static constexpr const char *kGcpCloudRunJobTaskIndex = "gcp.cloud_run.job.task_index"; +/** + * The hostname of a GCE instance. This is the full value of the default or custom hostname. + */ +static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostname"; + /** * The instance name of a GCE instance. This is the value provided by {@code host.name}, the visible * name of the instance in the Cloud Console UI, and the prefix for the default hostname of the @@ -248,10 +261,14 @@ static constexpr const char *kGcpCloudRunJobTaskIndex = "gcp.cloud_run.job.task_ static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; /** - * The hostname of a GCE instance. This is the full value of the default or custom hostname. + * Unique identifier for the application */ -static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostname"; +static constexpr const char *kHerokuAppId = "heroku.app.id"; + +/** + * Commit hash for the current release + */ +static constexpr const char *kHerokuReleaseCommit = "heroku.release.commit"; /** * Time and date the release was created @@ -259,19 +276,23 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam static constexpr const char *kHerokuReleaseCreationTimestamp = "heroku.release.creation_timestamp"; /** - * Commit hash for the current release + * The command used to run the container (i.e. the command name). + * + *

Notes: +

  • If using embedded credentials or sensitive data, it is recommended to remove them to + prevent potential leakage.
*/ -static constexpr const char *kHerokuReleaseCommit = "heroku.release.commit"; +static constexpr const char *kContainerCommand = "container.command"; /** - * Unique identifier for the application + * All the command arguments (including the command/executable itself) run by the container. [2] */ -static constexpr const char *kHerokuAppId = "heroku.app.id"; +static constexpr const char *kContainerCommandArgs = "container.command_args"; /** - * Container name used by container runtime. + * The full command run by the container as a single string representing the full command. [2] */ -static constexpr const char *kContainerName = "container.name"; +static constexpr const char *kContainerCommandLine = "container.command_line"; /** * Container ID. Usually a UUID, as for example used to +The ID is assinged by the container runtime and can vary in different environments. Consider using +{@code oci.manifest.digest} if it is important to identify the same image in different +environments/runtimes. */ static constexpr const char *kContainerImageId = "container.image.id"; /** - * The command used to run the container (i.e. the command name). + * Name of the image the container was built on. + */ +static constexpr const char *kContainerImageName = "container.image.name"; + +/** + * Repo digests of the container image as provided by the container runtime. * *

Notes: -

  • If using embedded credentials or sensitive data, it is recommended to remove them to - prevent potential leakage.
+
  • Docker and CRI + report those under the {@code RepoDigests} field.
*/ -static constexpr const char *kContainerCommand = "container.command"; +static constexpr const char *kContainerImageRepoDigests = "container.image.repo_digests"; /** - * The full command run by the container as a single string representing the full command. [2] + * Container image tags. An example can be found in Docker Image + * Inspect. Should be only the {@code } section of the full name for example from {@code + * registry.example.com/my-org/my-image:}. */ -static constexpr const char *kContainerCommandLine = "container.command_line"; +static constexpr const char *kContainerImageTags = "container.image.tags"; /** - * All the command arguments (including the command/executable itself) run by the container. [2] + * Container name used by container runtime. */ -static constexpr const char *kContainerCommandArgs = "container.command_args"; +static constexpr const char *kContainerName = "container.name"; + +/** + * The container runtime managing this container. + */ +static constexpr const char *kContainerRuntime = "container.runtime"; /** * Name of the deployment @@ -352,6 +375,16 @@ static constexpr const char *kDeploymentEnvironment = "deployment.environment"; */ static constexpr const char *kDeviceId = "device.id"; +/** + * The name of the device manufacturer + * + *

Notes: +

+ */ +static constexpr const char *kDeviceManufacturer = "device.manufacturer"; + /** * The model identifier for the device * @@ -371,14 +404,25 @@ static constexpr const char *kDeviceModelIdentifier = "device.model.identifier"; static constexpr const char *kDeviceModelName = "device.model.name"; /** - * The name of the device manufacturer + * The execution environment ID as a string, that will be potentially reused for other invocations + to the same function/function version. * *

Notes: -

  • The Android OS provides this field via Build. iOS apps - SHOULD hardcode the value {@code Apple}.
+
  • AWS Lambda: Use the (full) log stream name.
  • +
*/ -static constexpr const char *kDeviceManufacturer = "device.manufacturer"; +static constexpr const char *kFaasInstance = "faas.instance"; + +/** + * The amount of memory available to the serverless function converted to Bytes. + * + *

Notes: +

  • 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 {@code + AWS_LAMBDA_FUNCTION_MEMORY_SIZE} provides this information (which must be multiplied by + 1,048,576).
+ */ +static constexpr const char *kFaasMaxMemory = "faas.max_memory"; /** * The name of the single function that this runtime instance executes. @@ -387,7 +431,7 @@ static constexpr const char *kDeviceManufacturer = "device.manufacturer";
  • This is the name of the function as configured/deployed on the FaaS platform and is usually different from the name of the callback function (which may be stored in the -{@code code.namespace}/{@code +{@code code.namespace}/{@code code.function} span attributes).
  • For some cloud providers, the above definition is ambiguous. The following definition of function name MUST be used for this attribute (and consequently the span name) for the listed cloud providers/products:
  • Azure: @@ -418,25 +462,9 @@ not set this attribute.
  • static constexpr const char *kFaasVersion = "faas.version"; /** - * The execution environment ID as a string, that will be potentially reused for other invocations - to the same function/function version. - * - *

    Notes: -

    • AWS Lambda: Use the (full) log stream name.
    • -
    - */ -static constexpr const char *kFaasInstance = "faas.instance"; - -/** - * The amount of memory available to the serverless function converted to Bytes. - * - *

    Notes: -

    • 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 {@code - AWS_LAMBDA_FUNCTION_MEMORY_SIZE} provides this information (which must be multiplied by - 1,048,576).
    + * The CPU architecture the host system is running on. */ -static constexpr const char *kFaasMaxMemory = "faas.max_memory"; +static constexpr const char *kHostArch = "host.arch"; /** * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For @@ -445,6 +473,32 @@ static constexpr const char *kFaasMaxMemory = "faas.max_memory"; */ static constexpr const char *kHostId = "host.id"; +/** + * VM image ID or host OS image ID. For Cloud, this value is from the provider. + */ +static constexpr const char *kHostImageId = "host.image.id"; + +/** + * Name of the VM image or OS install the host was instantiated from. + */ +static constexpr const char *kHostImageName = "host.image.name"; + +/** + * The version string of the VM image or host OS as defined in Version Attributes. + */ +static constexpr const char *kHostImageVersion = "host.image.version"; + +/** + * Available IP addresses of the host, excluding loopback interfaces. + * + *

    Notes: +

    • IPv4 Addresses MUST be specified in dotted-quad notation. IPv6 addresses MUST be + specified in the RFC 5952 format.
    • +
    + */ +static constexpr const char *kHostIp = "host.ip"; + /** * 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. @@ -457,25 +511,40 @@ static constexpr const char *kHostName = "host.name"; static constexpr const char *kHostType = "host.type"; /** - * The CPU architecture the host system is running on. + * The amount of level 2 memory cache available to the processor (in Bytes). */ -static constexpr const char *kHostArch = "host.arch"; +static constexpr const char *kHostCpuCacheL2Size = "host.cpu.cache.l2.size"; /** - * Name of the VM image or OS install the host was instantiated from. + * Numeric value specifying the family or generation of the CPU. */ -static constexpr const char *kHostImageName = "host.image.name"; +static constexpr const char *kHostCpuFamily = "host.cpu.family"; /** - * VM image ID or host OS image ID. For Cloud, this value is from the provider. + * Model identifier. It provides more granular information about the CPU, distinguishing it from + * other CPUs within the same family. */ -static constexpr const char *kHostImageId = "host.image.id"; +static constexpr const char *kHostCpuModelId = "host.cpu.model.id"; /** - * The version string of the VM image or host OS as defined in Version Attributes. + * Model designation of the processor. */ -static constexpr const char *kHostImageVersion = "host.image.version"; +static constexpr const char *kHostCpuModelName = "host.cpu.model.name"; + +/** + * Stepping or core revisions. + */ +static constexpr const char *kHostCpuStepping = "host.cpu.stepping"; + +/** + * Processor manufacturer identifier. A maximum 12-character string. + * + *

    Notes: +

    • CPUID command returns the vendor ID string in + EBX, EDX and ECX registers. Writing these to memory in this order results in a 12-character + string.
    + */ +static constexpr const char *kHostCpuVendorId = "host.cpu.vendor.id"; /** * The name of the cluster. @@ -522,14 +591,14 @@ static constexpr const char *kK8sNodeUid = "k8s.node.uid"; static constexpr const char *kK8sNamespaceName = "k8s.namespace.name"; /** - * The UID of the Pod. + * The name of the Pod. */ -static constexpr const char *kK8sPodUid = "k8s.pod.uid"; +static constexpr const char *kK8sPodName = "k8s.pod.name"; /** - * The name of the Pod. + * The UID of the Pod. */ -static constexpr const char *kK8sPodName = "k8s.pod.name"; +static constexpr const char *kK8sPodUid = "k8s.pod.uid"; /** * The name of the Container from Pod specification, must be unique within a Pod. Container runtime @@ -543,15 +612,20 @@ static constexpr const char *kK8sContainerName = "k8s.container.name"; */ static constexpr const char *kK8sContainerRestartCount = "k8s.container.restart_count"; +/** + * The name of the ReplicaSet. + */ +static constexpr const char *kK8sReplicasetName = "k8s.replicaset.name"; + /** * The UID of the ReplicaSet. */ static constexpr const char *kK8sReplicasetUid = "k8s.replicaset.uid"; /** - * The name of the ReplicaSet. + * The name of the Deployment. */ -static constexpr const char *kK8sReplicasetName = "k8s.replicaset.name"; +static constexpr const char *kK8sDeploymentName = "k8s.deployment.name"; /** * The UID of the Deployment. @@ -559,9 +633,9 @@ static constexpr const char *kK8sReplicasetName = "k8s.replicaset.name"; static constexpr const char *kK8sDeploymentUid = "k8s.deployment.uid"; /** - * The name of the Deployment. + * The name of the StatefulSet. */ -static constexpr const char *kK8sDeploymentName = "k8s.deployment.name"; +static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; /** * The UID of the StatefulSet. @@ -569,9 +643,9 @@ static constexpr const char *kK8sDeploymentName = "k8s.deployment.name"; static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; /** - * The name of the StatefulSet. + * The name of the DaemonSet. */ -static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; +static constexpr const char *kK8sDaemonsetName = "k8s.daemonset.name"; /** * The UID of the DaemonSet. @@ -579,9 +653,9 @@ static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; static constexpr const char *kK8sDaemonsetUid = "k8s.daemonset.uid"; /** - * The name of the DaemonSet. + * The name of the Job. */ -static constexpr const char *kK8sDaemonsetName = "k8s.daemonset.name"; +static constexpr const char *kK8sJobName = "k8s.job.name"; /** * The UID of the Job. @@ -589,9 +663,9 @@ static constexpr const char *kK8sDaemonsetName = "k8s.daemonset.name"; static constexpr const char *kK8sJobUid = "k8s.job.uid"; /** - * The name of the Job. + * The name of the CronJob. */ -static constexpr const char *kK8sJobName = "k8s.job.name"; +static constexpr const char *kK8sCronjobName = "k8s.cronjob.name"; /** * The UID of the CronJob. @@ -599,14 +673,23 @@ static constexpr const char *kK8sJobName = "k8s.job.name"; static constexpr const char *kK8sCronjobUid = "k8s.cronjob.uid"; /** - * The name of the CronJob. + * The digest of the OCI image manifest. For container images specifically is the digest by which +the container image is known. + * + *

    Notes: +

    */ -static constexpr const char *kK8sCronjobName = "k8s.cronjob.name"; +static constexpr const char *kOciManifestDigest = "oci.manifest.digest"; /** - * The operating system type. + * Unique identifier for a particular build or compilation of the operating system. */ -static constexpr const char *kOsType = "os.type"; +static constexpr const char *kOsBuildId = "os.build_id"; /** * Human readable (not intended to be parsed) OS version information, like e.g. reported by {@code @@ -619,6 +702,11 @@ static constexpr const char *kOsDescription = "os.description"; */ static constexpr const char *kOsName = "os.name"; +/** + * The operating system type. + */ +static constexpr const char *kOsType = "os.type"; + /** * The version string of the operating system as defined in Version Attributes. @@ -626,14 +714,26 @@ static constexpr const char *kOsName = "os.name"; static constexpr const char *kOsVersion = "os.version"; /** - * Process identifier (PID). + * The command used to launch the process (i.e. the command name). On Linux based systems, can be + * set to the zeroth string in {@code proc/[pid]/cmdline}. On Windows, can be set to the first + * parameter extracted from {@code GetCommandLineW}. */ -static constexpr const char *kProcessPid = "process.pid"; +static constexpr const char *kProcessCommand = "process.command"; /** - * Parent Process identifier (PID). + * 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 {@code proc/[pid]/cmdline}. For libc-based + * executables, this would be the full argv vector passed to {@code main}. */ -static constexpr const char *kProcessParentPid = "process.parent_pid"; +static constexpr const char *kProcessCommandArgs = "process.command_args"; + +/** + * 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 {@code GetCommandLineW}. Do not set this if you have to + * assemble it just for monitoring; use {@code process.command_args} instead. + */ +static constexpr const char *kProcessCommandLine = "process.command_line"; /** * The name of the process executable. On Linux based systems, can be set to the {@code Name} in @@ -649,31 +749,25 @@ static constexpr const char *kProcessExecutableName = "process.executable.name"; static constexpr const char *kProcessExecutablePath = "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 {@code proc/[pid]/cmdline}. On Windows, can be set to the first - * parameter extracted from {@code GetCommandLineW}. + * The username of the user that owns the process. */ -static constexpr const char *kProcessCommand = "process.command"; +static constexpr const char *kProcessOwner = "process.owner"; /** - * 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 {@code GetCommandLineW}. Do not set this if you have to - * assemble it just for monitoring; use {@code process.command_args} instead. + * Parent Process identifier (PID). */ -static constexpr const char *kProcessCommandLine = "process.command_line"; +static constexpr const char *kProcessParentPid = "process.parent_pid"; /** - * 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 {@code proc/[pid]/cmdline}. For libc-based - * executables, this would be the full argv vector passed to {@code main}. + * Process identifier (PID). */ -static constexpr const char *kProcessCommandArgs = "process.command_args"; +static constexpr const char *kProcessPid = "process.pid"; /** - * The username of the user that owns the process. + * An additional description about the runtime of the process, for example a specific vendor + * customization of the runtime environment. */ -static constexpr const char *kProcessOwner = "process.owner"; +static constexpr const char *kProcessRuntimeDescription = "process.runtime.description"; /** * The name of the runtime of this process. For compiled native binaries, this SHOULD be the name of @@ -686,12 +780,6 @@ static constexpr const char *kProcessRuntimeName = "process.runtime.name"; */ static constexpr const char *kProcessRuntimeVersion = "process.runtime.version"; -/** - * An additional description about the runtime of the process, for example a specific vendor - * customization of the runtime environment. - */ -static constexpr const char *kProcessRuntimeDescription = "process.runtime.description"; - /** * Logical name of the service. * @@ -710,19 +798,6 @@ static constexpr const char *kServiceName = "service.name"; */ static constexpr const char *kServiceVersion = "service.version"; -/** - * A namespace for {@code service.name}. - * - *

    Notes: -

    • 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. {@code service.name} is expected to be unique - within the same namespace. If {@code service.namespace} is not specified in the Resource then - {@code 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.
    - */ -static constexpr const char *kServiceNamespace = "service.namespace"; - /** * The string ID of the service instance. * @@ -739,6 +814,24 @@ static constexpr const char *kServiceNamespace = "service.namespace"; */ static constexpr const char *kServiceInstanceId = "service.instance.id"; +/** + * A namespace for {@code service.name}. + * + *

    Notes: +

    • 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. {@code service.name} is expected to be unique + within the same namespace. If {@code service.namespace} is not specified in the Resource then + {@code 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.
    + */ +static constexpr const char *kServiceNamespace = "service.namespace"; + +/** + * The language of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkLanguage = "telemetry.sdk.language"; + /** * The name of the telemetry SDK as defined above. * @@ -754,19 +847,29 @@ stable across different versions of an implementation.
static constexpr const char *kTelemetrySdkName = "telemetry.sdk.name"; /** - * The language of the telemetry SDK. + * The version string of the telemetry SDK. */ -static constexpr const char *kTelemetrySdkLanguage = "telemetry.sdk.language"; +static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; /** - * The version string of the telemetry SDK. + * The name of the auto instrumentation agent or distribution, if used. + * + *

Notes: +

  • Official auto instrumentation agents and distributions SHOULD set the {@code +telemetry.distro.name} attribute to a string starting with {@code opentelemetry-}, e.g. {@code +opentelemetry-java-instrumentation}.
*/ -static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; +static constexpr const char *kTelemetryDistroName = "telemetry.distro.name"; /** - * The version string of the auto instrumentation agent, if used. + * The version string of the auto instrumentation agent or distribution, if used. */ -static constexpr const char *kTelemetryAutoVersion = "telemetry.auto.version"; +static constexpr const char *kTelemetryDistroVersion = "telemetry.distro.version"; + +/** + * Additional description of the web engine (e.g. detailed version and edition information). + */ +static constexpr const char *kWebengineDescription = "webengine.description"; /** * The name of the web engine. @@ -778,11 +881,6 @@ static constexpr const char *kWebengineName = "webengine.name"; */ static constexpr const char *kWebengineVersion = "webengine.version"; -/** - * Additional description of the web engine (e.g. detailed version and edition information). - */ -static constexpr const char *kWebengineDescription = "webengine.description"; - /** * The name of the instrumentation scope - ({@code InstrumentationScope.Name} in OTLP). */ @@ -810,24 +908,6 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryVersion = "otel.library.version"; // Enum definitions -namespace CloudProviderValues -{ -/** Alibaba Cloud. */ -static constexpr const char *kAlibabaCloud = "alibaba_cloud"; -/** Amazon Web Services. */ -static constexpr const char *kAws = "aws"; -/** Microsoft Azure. */ -static constexpr const char *kAzure = "azure"; -/** Google Cloud Platform. */ -static constexpr const char *kGcp = "gcp"; -/** Heroku Platform as a Service. */ -static constexpr const char *kHeroku = "heroku"; -/** IBM Cloud. */ -static constexpr const char *kIbmCloud = "ibm_cloud"; -/** Tencent Cloud. */ -static constexpr const char *kTencentCloud = "tencent_cloud"; -} // namespace CloudProviderValues - namespace CloudPlatformValues { /** Alibaba Cloud Elastic Compute Service. */ @@ -886,6 +966,24 @@ static constexpr const char *kTencentCloudEks = "tencent_cloud_eks"; static constexpr const char *kTencentCloudScf = "tencent_cloud_scf"; } // namespace CloudPlatformValues +namespace CloudProviderValues +{ +/** Alibaba Cloud. */ +static constexpr const char *kAlibabaCloud = "alibaba_cloud"; +/** Amazon Web Services. */ +static constexpr const char *kAws = "aws"; +/** Microsoft Azure. */ +static constexpr const char *kAzure = "azure"; +/** Google Cloud Platform. */ +static constexpr const char *kGcp = "gcp"; +/** Heroku Platform as a Service. */ +static constexpr const char *kHeroku = "heroku"; +/** IBM Cloud. */ +static constexpr const char *kIbmCloud = "ibm_cloud"; +/** Tencent Cloud. */ +static constexpr const char *kTencentCloud = "tencent_cloud"; +} // namespace CloudProviderValues + namespace AwsEcsLaunchtypeValues { /** ec2. */ diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index 092db1eaf8..ce2a6d4401 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -63,10 +63,23 @@ class TracerProvider final : public opentelemetry::trace::TracerProvider ~TracerProvider() override; + /* + Make sure GetTracer() helpers from the API are seen in overload resolution. + */ + using opentelemetry::trace::TracerProvider::GetTracer; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + opentelemetry::nostd::shared_ptr GetTracer( + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const opentelemetry::common::KeyValueIterable *attributes) noexcept override; +#else opentelemetry::nostd::shared_ptr GetTracer( - nostd::string_view library_name, - nostd::string_view library_version = "", - nostd::string_view schema_url = "") noexcept override; + nostd::string_view name, + nostd::string_view version = "", + nostd::string_view schema_url = "") noexcept override; +#endif /** * Attaches a span processor to list of configured processors for this tracer provider. diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index b790af4574..16bd121b92 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -5,7 +5,7 @@ #include "opentelemetry/detail/preprocessor.h" -#define OPENTELEMETRY_SDK_VERSION "1.11.0" +#define OPENTELEMETRY_SDK_VERSION "1.12.0" #include "opentelemetry/version.h" diff --git a/sdk/src/metrics/async_instruments.cc b/sdk/src/metrics/async_instruments.cc index 082d6713b4..5ca56b3969 100644 --- a/sdk/src/metrics/async_instruments.cc +++ b/sdk/src/metrics/async_instruments.cc @@ -21,6 +21,11 @@ ObservableInstrument::ObservableInstrument(InstrumentDescriptor instrument_descr {} +ObservableInstrument::~ObservableInstrument() +{ + observable_registry_->CleanupCallback(this); +} + void ObservableInstrument::AddCallback(opentelemetry::metrics::ObservableCallbackPtr callback, void *state) noexcept { diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 23ddbc75cf..63bea5ae28 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -75,7 +75,7 @@ nostd::shared_ptr MeterProvider::GetMeter( return nostd::shared_ptr{meter}; } -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 void MeterProvider::RemoveMeter(nostd::string_view name, nostd::string_view version, nostd::string_view schema_url) noexcept diff --git a/sdk/src/metrics/state/observable_registry.cc b/sdk/src/metrics/state/observable_registry.cc index 0296167b05..41b8e86067 100644 --- a/sdk/src/metrics/state/observable_registry.cc +++ b/sdk/src/metrics/state/observable_registry.cc @@ -38,6 +38,16 @@ void ObservableRegistry::RemoveCallback(opentelemetry::metrics::ObservableCallba callbacks_.erase(new_end, callbacks_.end()); } +void ObservableRegistry::CleanupCallback(opentelemetry::metrics::ObservableInstrument *instrument) +{ + std::lock_guard lock_guard{callbacks_m_}; + auto iter = std::remove_if(callbacks_.begin(), callbacks_.end(), + [instrument](const std::unique_ptr &record) { + return record->instrument == instrument; + }); + callbacks_.erase(iter, callbacks_.end()); +} + void ObservableRegistry::Observe(opentelemetry::common::SystemTimestamp collection_ts) { std::lock_guard lock_guard{callbacks_m_}; diff --git a/sdk/src/metrics/view/instrument_selector_factory.cc b/sdk/src/metrics/view/instrument_selector_factory.cc index 98a587ea62..5cf4a5b968 100644 --- a/sdk/src/metrics/view/instrument_selector_factory.cc +++ b/sdk/src/metrics/view/instrument_selector_factory.cc @@ -13,8 +13,8 @@ namespace metrics std::unique_ptr InstrumentSelectorFactory::Create( opentelemetry::sdk::metrics::InstrumentType instrument_type, - opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view unit) + const std::string &name, + const std::string &unit) { std::unique_ptr instrument_selector( new InstrumentSelector(instrument_type, name, unit)); diff --git a/sdk/src/metrics/view/meter_selector_factory.cc b/sdk/src/metrics/view/meter_selector_factory.cc index f8f906d9ad..088dcd864e 100644 --- a/sdk/src/metrics/view/meter_selector_factory.cc +++ b/sdk/src/metrics/view/meter_selector_factory.cc @@ -11,10 +11,9 @@ namespace sdk namespace metrics { -std::unique_ptr MeterSelectorFactory::Create( - opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view version, - opentelemetry::nostd::string_view schema) +std::unique_ptr MeterSelectorFactory::Create(const std::string &name, + const std::string &version, + const std::string &schema) { std::unique_ptr meter_selector(new MeterSelector(name, version, schema)); return meter_selector; diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index c7524d43aa..25708cddd9 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -146,6 +146,35 @@ void Span::AddEvent(nostd::string_view name, recordable_->AddEvent(name, timestamp, attributes); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +void Span::AddLink(const opentelemetry::trace::SpanContext &target, + const opentelemetry::common::KeyValueIterable &attrs) noexcept +{ + std::lock_guard lock_guard{mu_}; + if (recordable_ == nullptr) + { + return; + } + + recordable_->AddLink(target, attrs); +} + +void Span::AddLinks(const opentelemetry::trace::SpanContextKeyValueIterable &links) noexcept +{ + std::lock_guard lock_guard{mu_}; + if (recordable_ == nullptr) + { + return; + } + + links.ForEachKeyValue([&](opentelemetry::trace::SpanContext span_context, + const common::KeyValueIterable &attributes) { + recordable_->AddLink(span_context, attributes); + return true; + }); +} +#endif + void Span::SetStatus(opentelemetry::trace::StatusCode code, nostd::string_view description) noexcept { std::lock_guard lock_guard{mu_}; diff --git a/sdk/src/trace/span.h b/sdk/src/trace/span.h index 75e31e9500..eb603b9025 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -42,6 +42,13 @@ class Span final : public opentelemetry::trace::Span opentelemetry::common::SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) noexcept override; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const opentelemetry::trace::SpanContext &target, + const opentelemetry::common::KeyValueIterable &attrs) noexcept override; + + void AddLinks(const opentelemetry::trace::SpanContextKeyValueIterable &links) noexcept override; +#endif + void SetStatus(opentelemetry::trace::StatusCode code, nostd::string_view description) noexcept override; diff --git a/sdk/src/trace/tracer_provider.cc b/sdk/src/trace/tracer_provider.cc index 13d56f9966..8569b63f23 100644 --- a/sdk/src/trace/tracer_provider.cc +++ b/sdk/src/trace/tracer_provider.cc @@ -53,17 +53,29 @@ TracerProvider::~TracerProvider() } } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 nostd::shared_ptr TracerProvider::GetTracer( - nostd::string_view library_name, - nostd::string_view library_version, + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const opentelemetry::common::KeyValueIterable *attributes) noexcept +#else +nostd::shared_ptr TracerProvider::GetTracer( + nostd::string_view name, + nostd::string_view version, nostd::string_view schema_url) noexcept +#endif { - if (library_name.data() == nullptr) +#if OPENTELEMETRY_ABI_VERSION_NO < 2 + const opentelemetry::common::KeyValueIterable *attributes = nullptr; +#endif + + if (name.data() == nullptr) { OTEL_INTERNAL_LOG_ERROR("[TracerProvider::GetTracer] Library name is null."); - library_name = ""; + name = ""; } - else if (library_name == "") + else if (name == "") { OTEL_INTERNAL_LOG_ERROR("[TracerProvider::GetTracer] Library name is empty."); } @@ -72,17 +84,20 @@ nostd::shared_ptr TracerProvider::GetTracer( for (auto &tracer : tracers_) { - auto &tracer_lib = tracer->GetInstrumentationScope(); - if (tracer_lib.equal(library_name, library_version, schema_url)) + auto &tracer_scope = tracer->GetInstrumentationScope(); + if (tracer_scope.equal(name, version, schema_url)) { return nostd::shared_ptr{tracer}; } } - auto lib = InstrumentationScope::Create(library_name, library_version, schema_url); - tracers_.push_back(std::shared_ptr( - new sdk::trace::Tracer(context_, std::move(lib)))); - return nostd::shared_ptr{tracers_.back()}; + instrumentationscope::InstrumentationScopeAttributes attrs_map(attributes); + auto scope = + instrumentationscope::InstrumentationScope::Create(name, version, schema_url, attrs_map); + + auto tracer = std::shared_ptr(new Tracer(context_, std::move(scope))); + tracers_.push_back(tracer); + return nostd::shared_ptr{tracer}; } void TracerProvider::AddProcessor(std::unique_ptr processor) noexcept diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index 34175bd4e4..fb2db64c30 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 11; +const int minor_version = 12; const int patch_version = 0; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.11.0"; -const char *full_version = "1.11.0-NONE-NONE"; -const char *build_date = "Mon Aug 21 22:31:07 UTC 2023"; +const char *short_version = "1.12.0"; +const char *full_version = "1.12.0-NONE-NONE"; +const char *build_date = "Mon 16 Oct 2023 07:42:23 AM UTC"; } // namespace version } // namespace sdk diff --git a/sdk/test/metrics/meter_provider_sdk_test.cc b/sdk/test/metrics/meter_provider_sdk_test.cc index 1844f113d2..ce79b563c1 100644 --- a/sdk/test/metrics/meter_provider_sdk_test.cc +++ b/sdk/test/metrics/meter_provider_sdk_test.cc @@ -191,7 +191,7 @@ TEST(MeterProvider, GetMeterAbiv2) } #endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 TEST(MeterProvider, RemoveMeter) { MeterProvider mp; @@ -225,4 +225,4 @@ TEST(MeterProvider, RemoveMeter) mp.ForceFlush(); mp.Shutdown(); } -#endif +#endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ diff --git a/sdk/test/metrics/sum_aggregation_test.cc b/sdk/test/metrics/sum_aggregation_test.cc index b355f134ed..403bf34b22 100644 --- a/sdk/test/metrics/sum_aggregation_test.cc +++ b/sdk/test/metrics/sum_aggregation_test.cc @@ -121,8 +121,12 @@ TEST(CounterToSum, Double) ASSERT_EQ(1000275.0, opentelemetry::nostd::get(actual.value_)); } -TEST(UpDownCounterToSum, Double) +class UpDownCounterToSumFixture : public ::testing::TestWithParam +{}; + +TEST_P(UpDownCounterToSumFixture, Double) { + bool is_matching_view = GetParam(); MeterProvider mp; auto m = mp.GetMeter("meter1", "version1", "schema1"); std::string instrument_name = "updowncounter1"; @@ -133,13 +137,16 @@ TEST(UpDownCounterToSum, Double) std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; mp.AddMetricReader(reader); - std::unique_ptr view{ - new View("view1", "view1_description", instrument_unit, AggregationType::kSum)}; - std::unique_ptr instrument_selector{ - new InstrumentSelector(InstrumentType::kUpDownCounter, instrument_name, instrument_unit)}; - std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; - mp.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); - + if (is_matching_view) + { + std::unique_ptr view{ + new View("view1", "view1_description", instrument_unit, AggregationType::kSum)}; + std::unique_ptr instrument_selector{ + new InstrumentSelector(InstrumentType::kUpDownCounter, instrument_name, instrument_unit)}; + std::unique_ptr meter_selector{ + new MeterSelector("meter1", "version1", "schema1")}; + mp.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); + } auto h = m->CreateDoubleUpDownCounter(instrument_name, instrument_desc, instrument_unit); h->Add(5, {}); @@ -168,4 +175,7 @@ TEST(UpDownCounterToSum, Double) const auto &actual = actuals.at(0); ASSERT_EQ(15.0, opentelemetry::nostd::get(actual.value_)); } +INSTANTIATE_TEST_SUITE_P(UpDownCounterToSum, + UpDownCounterToSumFixture, + ::testing::Values(true, false)); #endif diff --git a/sdk/test/trace/tracer_provider_test.cc b/sdk/test/trace/tracer_provider_test.cc index 364efc0208..8e1b22fb62 100644 --- a/sdk/test/trace/tracer_provider_test.cc +++ b/sdk/test/trace/tracer_provider_test.cc @@ -78,6 +78,143 @@ TEST(TracerProvider, GetTracer) ASSERT_EQ(instrumentation_scope3.GetVersion(), "1.0.0"); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +TEST(TracerProvider, GetTracerAbiv2) +{ + std::unique_ptr processor(new SimpleSpanProcessor(nullptr)); + std::vector> processors; + processors.push_back(std::move(processor)); + std::unique_ptr context1( + new TracerContext(std::move(processors), Resource::Create({}))); + TracerProvider tp(std::move(context1)); + + auto t1 = tp.GetTracer("name1", "version1", "url1"); + ASSERT_NE(nullptr, t1); + + auto t2 = tp.GetTracer("name2", "version2", "url2", nullptr); + ASSERT_NE(nullptr, t2); + + auto t3 = tp.GetTracer("name3", "version3", "url3", {{"accept_single_attr", true}}); + ASSERT_NE(nullptr, t3); + { + auto tracer = static_cast(t3.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + auto attr = attrs.find("accept_single_attr"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), true); + } + + std::pair attr4 = { + "accept_single_attr", true}; + auto t4 = tp.GetTracer("name4", "version4", "url4", {attr4}); + ASSERT_NE(nullptr, t4); + { + auto tracer = static_cast(t4.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + auto attr = attrs.find("accept_single_attr"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), true); + } + + auto t5 = tp.GetTracer("name5", "version5", "url5", {{"foo", "1"}, {"bar", "2"}}); + ASSERT_NE(nullptr, t5); + { + auto tracer = static_cast(t5.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + auto attr = attrs.find("bar"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), "2"); + } + + std::initializer_list< + std::pair> + attrs6 = {{"foo", "1"}, {"bar", 42}}; + + auto t6 = tp.GetTracer("name6", "version6", "url6", attrs6); + ASSERT_NE(nullptr, t6); + { + auto tracer = static_cast(t6.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + auto attr = attrs.find("bar"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), 42); + } + + typedef std::pair KV; + + std::initializer_list attrs7 = {{"foo", 3.14}, {"bar", "2"}}; + auto t7 = tp.GetTracer("name7", "version7", "url7", attrs7); + ASSERT_NE(nullptr, t7); + { + auto tracer = static_cast(t7.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + auto attr = attrs.find("foo"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), 3.14); + } + + auto t8 = tp.GetTracer("name8", "version8", "url8", + {{"a", "string"}, + {"b", false}, + {"c", 314159}, + {"d", (unsigned int)314159}, + {"e", (int32_t)-20}, + {"f", (uint32_t)20}, + {"g", (int64_t)-20}, + {"h", (uint64_t)20}, + {"i", 3.1}, + {"j", "string"}}); + ASSERT_NE(nullptr, t8); + { + auto tracer = static_cast(t8.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 10); + auto attr = attrs.find("e"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), -20); + } + + std::map attr9{ + {"a", "string"}, {"b", false}, {"c", 314159}, {"d", (unsigned int)314159}, + {"e", (int32_t)-20}, {"f", (uint32_t)20}, {"g", (int64_t)-20}, {"h", (uint64_t)20}, + {"i", 3.1}, {"j", "string"}}; + + auto t9 = tp.GetTracer("name9", "version9", "url9", attr9); + ASSERT_NE(nullptr, t9); + { + auto tracer = static_cast(t9.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 10); + auto attr = attrs.find("h"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), 20); + } + + // cleanup properly without crash + tp.ForceFlush(); + tp.Shutdown(); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ + TEST(TracerProvider, Shutdown) { std::unique_ptr processor(new SimpleSpanProcessor(nullptr)); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 45b5fc010f..36cc135a1d 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -519,6 +519,392 @@ TEST(Tracer, SpanSetLinks) } } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +TEST(Tracer, SpanAddLinkAbiv2) +{ + InMemorySpanExporter *exporter = new InMemorySpanExporter(); + std::shared_ptr span_data = exporter->GetData(); + auto tracer = initTracer(std::unique_ptr{exporter}); + + { + auto span = tracer->StartSpan("span"); + SpanContext target(false, false); + // Single link attribute passed through Initialization list + span->AddLink(target, {{"attr2", 2}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(1, span_data_links.size()); + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(nostd::get(attrs.at("attr2")), 2); + } + + { + auto span = tracer->StartSpan("span"); + SpanContext target(false, false); + // Multiple link attributes passed through Initialization list + span->AddLink(target, {{"attr2", 2}, {"attr3", 3}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(1, span_data_links.size()); + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(nostd::get(attrs.at("attr2")), 2); + ASSERT_EQ(nostd::get(attrs.at("attr3")), 3); + } + + { + std::map attrs_map = {{"attr1", "1"}, {"attr2", "2"}}; + + auto span = tracer->StartSpan("span"); + SpanContext target(false, false); + span->AddLink(target, attrs_map); + span->End(); + + auto spans = span_data->GetSpans(); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(1, span_data_links.size()); + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(nostd::get(attrs.at("attr1")), "1"); + ASSERT_EQ(nostd::get(attrs.at("attr2")), "2"); + } + + { + auto span = tracer->StartSpan("span"); + SpanContext target(false, false); + + // Single link attribute passed through Initialization list + span->AddLink(target, {{"attr1", 1}}); + + // Multiple link attributes passed through Initialization list + span->AddLink(target, {{"attr2", 2}, {"attr3", 3}}); + + std::map attrs_map = {{"attr4", "4"}, {"attr5", "5"}}; + span->AddLink(target, attrs_map); + + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(3, span_data_links.size()); + + { + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr1")), 1); + } + + { + auto link = span_data_links.at(1); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attr2")), 2); + ASSERT_EQ(nostd::get(attrs.at("attr3")), 3); + } + + { + auto link = span_data_links.at(2); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attr4")), "4"); + ASSERT_EQ(nostd::get(attrs.at("attr5")), "5"); + } + } +} + +TEST(Tracer, SpanAddLinksAbiv2) +{ + InMemorySpanExporter *exporter = new InMemorySpanExporter(); + std::shared_ptr span_data = exporter->GetData(); + auto tracer = initTracer(std::unique_ptr{exporter}); + + { + auto span = tracer->StartSpan("span"); + // Single span link passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr2", 2}}}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(1, span_data_links.size()); + auto link = span_data_links.at(0); + ASSERT_EQ(nostd::get(link.GetAttributes().at("attr2")), 2); + } + + { + auto span = tracer->StartSpan("span"); + // Multiple span links passed through Initialization list + span->AddLinks( + {{SpanContext(false, false), {{"attr2", 2}}}, {SpanContext(false, false), {{"attr3", 3}}}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(2, span_data_links.size()); + auto link1 = span_data_links.at(0); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr2")), 2); + auto link2 = span_data_links.at(1); + ASSERT_EQ(nostd::get(link2.GetAttributes().at("attr3")), 3); + } + + { + auto span = tracer->StartSpan("span"); + // Multiple links, each with multiple attributes passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr2", 2}, {"attr3", 3}}}, + {SpanContext(false, false), {{"attr4", 4}}}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(2, span_data_links.size()); + auto link1 = span_data_links.at(0); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr2")), 2); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr3")), 3); + auto link2 = span_data_links.at(1); + ASSERT_EQ(nostd::get(link2.GetAttributes().at("attr4")), 4); + } + + { + std::map attrs1 = {{"attr1", "1"}, {"attr2", "2"}}; + std::map attrs2 = {{"attr3", "3"}, {"attr4", "4"}}; + + std::vector>> links = { + {SpanContext(false, false), attrs1}, {SpanContext(false, false), attrs2}}; + + auto span = tracer->StartSpan("span"); + span->AddLinks(links); + span->End(); + + auto spans = span_data->GetSpans(); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(2, span_data_links.size()); + auto link1 = span_data_links.at(0); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr1")), "1"); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr2")), "2"); + auto link2 = span_data_links.at(1); + ASSERT_EQ(nostd::get(link2.GetAttributes().at("attr3")), "3"); + ASSERT_EQ(nostd::get(link2.GetAttributes().at("attr4")), "4"); + } + + { + auto span = tracer->StartSpan("span"); + + // Single span link passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr10", 10}}}}); + span->AddLinks({{SpanContext(false, false), {{"attr11", 11}}}}); + + // Multiple span links passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr12", 12}}}, + {SpanContext(false, false), {{"attr13", 13}}}}); + span->AddLinks({{SpanContext(false, false), {{"attr14", 14}}}, + {SpanContext(false, false), {{"attr15", 15}}}}); + + // Multiple links, each with multiple attributes passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr16", 16}, {"attr17", 17}}}, + {SpanContext(false, false), {{"attr18", 18}}}}); + span->AddLinks({{SpanContext(false, false), {{"attr19", 19}, {"attr20", 20}}}, + {SpanContext(false, false), {{"attr21", 21}}}}); + + std::map attrsa1 = {{"attra1", "1"}, {"attra2", "2"}}; + std::map attrsa2 = {{"attra3", "3"}, {"attra4", "4"}}; + + std::vector>> linksa = { + {SpanContext(false, false), attrsa1}, {SpanContext(false, false), attrsa2}}; + + span->AddLinks(linksa); + + std::map attrsb1 = {{"attrb1", "1"}, {"attrb2", "2"}}; + std::map attrsb2 = {{"attrb3", "3"}, {"attrb4", "4"}}; + + std::vector>> linksb = { + {SpanContext(false, false), attrsb1}, {SpanContext(false, false), attrsb2}}; + + span->AddLinks(linksb); + + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(14, span_data_links.size()); + + { + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr10")), 10); + } + + { + auto link = span_data_links.at(1); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr11")), 11); + } + + { + auto link = span_data_links.at(2); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr12")), 12); + } + + { + auto link = span_data_links.at(3); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr13")), 13); + } + + { + auto link = span_data_links.at(4); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr14")), 14); + } + + { + auto link = span_data_links.at(5); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr15")), 15); + } + + { + auto link = span_data_links.at(6); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attr16")), 16); + ASSERT_EQ(nostd::get(attrs.at("attr17")), 17); + } + + { + auto link = span_data_links.at(7); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr18")), 18); + } + + { + auto link = span_data_links.at(8); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attr19")), 19); + ASSERT_EQ(nostd::get(attrs.at("attr20")), 20); + } + + { + auto link = span_data_links.at(9); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr21")), 21); + } + + { + auto link = span_data_links.at(10); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attra1")), "1"); + ASSERT_EQ(nostd::get(attrs.at("attra2")), "2"); + } + + { + auto link = span_data_links.at(11); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attra3")), "3"); + ASSERT_EQ(nostd::get(attrs.at("attra4")), "4"); + } + + { + auto link = span_data_links.at(12); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attrb1")), "1"); + ASSERT_EQ(nostd::get(attrs.at("attrb2")), "2"); + } + + { + auto link = span_data_links.at(13); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attrb3")), "3"); + ASSERT_EQ(nostd::get(attrs.at("attrb4")), "4"); + } + } +} + +TEST(Tracer, SpanMixLinksAbiv2) +{ + InMemorySpanExporter *exporter = new InMemorySpanExporter(); + std::shared_ptr span_data = exporter->GetData(); + auto tracer = initTracer(std::unique_ptr{exporter}); + + { + // Link 1 added at StartSpan + auto span = + tracer->StartSpan("span", {{"attr1", 1}}, {{SpanContext(false, false), {{"attr2", 2}}}}); + + SpanContext target(false, false); + // Link 2 added with AddLink + span->AddLink(target, {{"attr3", 3}}); + + // Link 3 added with AddLinks + span->AddLinks({{SpanContext(false, false), {{"attr4", 4}}}}); + + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(3, span_data_links.size()); + + { + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr2")), 2); + } + + { + auto link = span_data_links.at(1); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr3")), 3); + } + + { + auto link = span_data_links.at(2); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr4")), 4); + } + } +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ + TEST(Tracer, TestAlwaysOnSampler) { InMemorySpanExporter *exporter = new InMemorySpanExporter();