From ca42ea09ba77f47890b31c4057896468d9f6d490 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Tue, 12 Nov 2024 16:26:45 +0100 Subject: [PATCH 01/19] deps: update undici adding code from https://github.com/nodejs/undici/pull/2701 PR-URL: https://github.com/nodesource/nsolid/pull/216 Reviewed-By: Rafael Gonzaga --- deps/undici/src/lib/core/diagnostics.js | 10 +- deps/undici/src/lib/web/fetch/index.js | 227 +++++++++++++++--------- deps/undici/undici.js | 150 +++++++++++----- 3 files changed, 254 insertions(+), 133 deletions(-) diff --git a/deps/undici/src/lib/core/diagnostics.js b/deps/undici/src/lib/core/diagnostics.js index e1af3db6112..c0b61daab01 100644 --- a/deps/undici/src/lib/core/diagnostics.js +++ b/deps/undici/src/lib/core/diagnostics.js @@ -6,6 +6,12 @@ const undiciDebugLog = util.debuglog('undici') const fetchDebuglog = util.debuglog('fetch') const websocketDebuglog = util.debuglog('websocket') let isClientSet = false +let tracingChannel + +if (diagnosticsChannel.tracingChannel) { + tracingChannel = diagnosticsChannel.tracingChannel('undici:fetch') +} + const channels = { // Client beforeConnect: diagnosticsChannel.channel('undici:client:beforeConnect'), @@ -23,7 +29,9 @@ const channels = { close: diagnosticsChannel.channel('undici:websocket:close'), socketError: diagnosticsChannel.channel('undici:websocket:socket_error'), ping: diagnosticsChannel.channel('undici:websocket:ping'), - pong: diagnosticsChannel.channel('undici:websocket:pong') + pong: diagnosticsChannel.channel('undici:websocket:pong'), + // Fetch channels + tracingChannel } if (undiciDebugLog.enabled || fetchDebuglog.enabled) { diff --git a/deps/undici/src/lib/web/fetch/index.js b/deps/undici/src/lib/web/fetch/index.js index 3c7ca211c99..5ce6af5db97 100644 --- a/deps/undici/src/lib/web/fetch/index.js +++ b/deps/undici/src/lib/web/fetch/index.js @@ -70,6 +70,7 @@ const defaultUserAgent = typeof __UNDICI_IS_NODE__ !== 'undefined' || typeof esb ? 'node' : 'undici' +const channels = require('../../core/diagnostics.js').channels.tracingChannel /** @type {import('buffer').resolveObjectURL} */ let resolveObjectURL @@ -124,12 +125,68 @@ function handleFetchDone (response) { finalizeAndReportTiming(response, 'fetch') } +// This will publish all diagnostic events only when we have subscribers. +function ifSubscribersRunStores (req, input, init, callback) { + const hasSubscribers = subscribersCheck() + + if (hasSubscribers) { + const context = { req, input, init, result: null, error: null } + + return channels.start.runStores(context, () => { + try { + return callback(createInstrumentedDeferredPromise(context)) + } catch (e) { + context.error = e + channels.error.publish(context) + throw e + } finally { + channels.end.publish(context) + } + }) + } else { + return callback(createDeferredPromise()) + } +} + +// subscribersCheck will be called at the beginning of the fetch call +// and will check if we have subscribers +function subscribersCheck () { + return channels && (channels.start.hasSubscribers || + channels.end.hasSubscribers || + channels.asyncStart.hasSubscribers || + channels.asyncEnd.hasSubscribers || + channels.error.hasSubscribers) +} + +function createInstrumentedDeferredPromise (context) { + let res + let rej + const promise = new Promise((resolve, reject) => { + res = function (result) { + context.result = result + channels.asyncStart.runStores(context, () => { + resolve(result) + channels.asyncEnd.publish(context) + }) + } + rej = function (error) { + context.error = error + channels.error.publish(context) + channels.asyncStart.runStores(context, () => { + reject(error) + channels.asyncEnd.publish(context) + }) + } + }) + + return { promise, resolve: res, reject: rej } +} + // https://fetch.spec.whatwg.org/#fetch-method function fetch (input, init = undefined) { webidl.argumentLengthCheck(arguments, 1, 'globalThis.fetch') // 1. Let p be a new promise. - let p = createDeferredPromise() // 2. Let requestObject be the result of invoking the initial value of // Request as constructor with input and init as arguments. If this throws @@ -139,116 +196,117 @@ function fetch (input, init = undefined) { try { requestObject = new Request(input, init) } catch (e) { - p.reject(e) - return p.promise + return Promise.reject(e) } - // 3. Let request be requestObject’s request. - const request = requestObject[kState] + return ifSubscribersRunStores(requestObject, input, init, p => { + // 3. Let request be requestObject’s request. + const request = requestObject[kState] - // 4. If requestObject’s signal’s aborted flag is set, then: - if (requestObject.signal.aborted) { + // 4. If requestObject’s signal’s aborted flag is set, then: + if (requestObject.signal.aborted) { // 1. Abort the fetch() call with p, request, null, and // requestObject’s signal’s abort reason. - abortFetch(p, request, null, requestObject.signal.reason) + abortFetch(p, request, null, requestObject.signal.reason) - // 2. Return p. - return p.promise - } + // 2. Return p. + return p.promise + } - // 5. Let globalObject be request’s client’s global object. - const globalObject = request.client.globalObject + // 5. Let globalObject be request’s client’s global object. + const globalObject = request.client.globalObject - // 6. If globalObject is a ServiceWorkerGlobalScope object, then set - // request’s service-workers mode to "none". - if (globalObject?.constructor?.name === 'ServiceWorkerGlobalScope') { - request.serviceWorkers = 'none' - } + // 6. If globalObject is a ServiceWorkerGlobalScope object, then set + // request’s service-workers mode to "none". + if (globalObject?.constructor?.name === 'ServiceWorkerGlobalScope') { + request.serviceWorkers = 'none' + } - // 7. Let responseObject be null. - let responseObject = null + // 7. Let responseObject be null. + let responseObject = null - // 8. Let relevantRealm be this’s relevant Realm. + // 8. Let relevantRealm be this’s relevant Realm. - // 9. Let locallyAborted be false. - let locallyAborted = false + // 9. Let locallyAborted be false. + let locallyAborted = false - // 10. Let controller be null. - let controller = null + // 10. Let controller be null. + let controller = null - // 11. Add the following abort steps to requestObject’s signal: - addAbortListener( - requestObject.signal, - () => { - // 1. Set locallyAborted to true. - locallyAborted = true + // 11. Add the following abort steps to requestObject’s signal: + addAbortListener( + requestObject.signal, + () => { + // 1. Set locallyAborted to true. + locallyAborted = true - // 2. Assert: controller is non-null. - assert(controller != null) + // 2. Assert: controller is non-null. + assert(controller != null) - // 3. Abort controller with requestObject’s signal’s abort reason. - controller.abort(requestObject.signal.reason) + // 3. Abort controller with requestObject’s signal’s abort reason. + controller.abort(requestObject.signal.reason) - const realResponse = responseObject?.deref() + const realResponse = responseObject?.deref() - // 4. Abort the fetch() call with p, request, responseObject, - // and requestObject’s signal’s abort reason. - abortFetch(p, request, realResponse, requestObject.signal.reason) - } - ) + // 4. Abort the fetch() call with p, request, responseObject, + // and requestObject’s signal’s abort reason. + abortFetch(p, request, realResponse, requestObject.signal.reason) + } + ) - // 12. Let handleFetchDone given response response be to finalize and - // report timing with response, globalObject, and "fetch". - // see function handleFetchDone + // 12. Let handleFetchDone given response response be to finalize and + // report timing with response, globalObject, and "fetch". + // see function handleFetchDone - // 13. Set controller to the result of calling fetch given request, - // with processResponseEndOfBody set to handleFetchDone, and processResponse - // given response being these substeps: + // 13. Set controller to the result of calling fetch given request, + // with processResponseEndOfBody set to handleFetchDone, and processResponse + // given response being these substeps: - const processResponse = (response) => { - // 1. If locallyAborted is true, terminate these substeps. - if (locallyAborted) { - return - } + const processResponse = (response) => { + // 1. If locallyAborted is true, terminate these substeps. + if (locallyAborted) { + return + } - // 2. If response’s aborted flag is set, then: - if (response.aborted) { - // 1. Let deserializedError be the result of deserialize a serialized - // abort reason given controller’s serialized abort reason and - // relevantRealm. + // 2. If response’s aborted flag is set, then: + if (response.aborted) { + // 1. Let deserializedError be the result of deserialize a serialized + // abort reason given controller’s serialized abort reason and + // relevantRealm. - // 2. Abort the fetch() call with p, request, responseObject, and - // deserializedError. + // 2. Abort the fetch() call with p, request, responseObject, and + // deserializedError. - abortFetch(p, request, responseObject, controller.serializedAbortReason) - return - } + abortFetch(p, request, responseObject, controller.serializedAbortReason) + return + } - // 3. If response is a network error, then reject p with a TypeError - // and terminate these substeps. - if (response.type === 'error') { - p.reject(new TypeError('fetch failed', { cause: response.error })) - return - } + // 3. If response is a network error, then reject p with a TypeError + // and terminate these substeps. + if (response.type === 'error') { + p.reject(new TypeError('fetch failed', { cause: response.error })) + return + } - // 4. Set responseObject to the result of creating a Response object, - // given response, "immutable", and relevantRealm. - responseObject = new WeakRef(fromInnerResponse(response, 'immutable')) + // 4. Set responseObject to the result of creating a Response object, + // given response, "immutable", and relevantRealm. + responseObject = new WeakRef(fromInnerResponse(response, 'immutable')) - // 5. Resolve p with responseObject. - p.resolve(responseObject.deref()) - p = null - } + // 5. Resolve p with responseObject. + p.resolve(responseObject.deref()) + p = null + } - controller = fetching({ - request, - processResponseEndOfBody: handleFetchDone, - processResponse, - dispatcher: requestObject[kDispatcher] // undici - }) + controller = fetching({ + request, + processResponseEndOfBody: handleFetchDone, + processResponse, + dispatcher: requestObject[kDispatcher] // undici + }) - // 14. Return p. - return p.promise + // 14. Return p. + return p.promise + }) } // https://fetch.spec.whatwg.org/#finalize-and-report-timing @@ -444,7 +502,8 @@ function fetching ({ // 9. If request’s origin is "client", then set request’s origin to request’s // client’s origin. if (request.origin === 'client') { - request.origin = request.client.origin + // TODO: What if request.client is null? + request.origin = request.client?.origin } // 10. If all of the following conditions are true: diff --git a/deps/undici/undici.js b/deps/undici/undici.js index 34796507bd7..27382c2d341 100644 --- a/deps/undici/undici.js +++ b/deps/undici/undici.js @@ -1678,6 +1678,10 @@ var require_diagnostics = __commonJS({ var fetchDebuglog = util.debuglog("fetch"); var websocketDebuglog = util.debuglog("websocket"); var isClientSet = false; + var tracingChannel; + if (diagnosticsChannel.tracingChannel) { + tracingChannel = diagnosticsChannel.tracingChannel("undici:fetch"); + } var channels = { // Client beforeConnect: diagnosticsChannel.channel("undici:client:beforeConnect"), @@ -1695,7 +1699,9 @@ var require_diagnostics = __commonJS({ close: diagnosticsChannel.channel("undici:websocket:close"), socketError: diagnosticsChannel.channel("undici:websocket:socket_error"), ping: diagnosticsChannel.channel("undici:websocket:ping"), - pong: diagnosticsChannel.channel("undici:websocket:pong") + pong: diagnosticsChannel.channel("undici:websocket:pong"), + // Fetch channels + tracingChannel }; if (undiciDebugLog.enabled || fetchDebuglog.enabled) { const debuglog = fetchDebuglog.enabled ? fetchDebuglog : undiciDebugLog; @@ -10157,6 +10163,7 @@ var require_fetch = __commonJS({ var { STATUS_CODES } = require("node:http"); var GET_OR_HEAD = ["GET", "HEAD"]; var defaultUserAgent = typeof __UNDICI_IS_NODE__ !== "undefined" || true ? "node" : "undici"; + var channels = require_diagnostics().channels.tracingChannel; var resolveObjectURL; var Fetch = class extends EE { static { @@ -10195,62 +10202,109 @@ var require_fetch = __commonJS({ finalizeAndReportTiming(response, "fetch"); } __name(handleFetchDone, "handleFetchDone"); + function ifSubscribersRunStores(req, input, init, callback) { + const hasSubscribers = subscribersCheck(); + if (hasSubscribers) { + const context = { req, input, init, result: null, error: null }; + return channels.start.runStores(context, () => { + try { + return callback(createInstrumentedDeferredPromise(context)); + } catch (e) { + context.error = e; + channels.error.publish(context); + throw e; + } finally { + channels.end.publish(context); + } + }); + } else { + return callback(createDeferredPromise()); + } + } + __name(ifSubscribersRunStores, "ifSubscribersRunStores"); + function subscribersCheck() { + return channels && (channels.start.hasSubscribers || channels.end.hasSubscribers || channels.asyncStart.hasSubscribers || channels.asyncEnd.hasSubscribers || channels.error.hasSubscribers); + } + __name(subscribersCheck, "subscribersCheck"); + function createInstrumentedDeferredPromise(context) { + let res; + let rej; + const promise = new Promise((resolve, reject) => { + res = /* @__PURE__ */ __name(function(result) { + context.result = result; + channels.asyncStart.runStores(context, () => { + resolve(result); + channels.asyncEnd.publish(context); + }); + }, "res"); + rej = /* @__PURE__ */ __name(function(error) { + context.error = error; + channels.error.publish(context); + channels.asyncStart.runStores(context, () => { + reject(error); + channels.asyncEnd.publish(context); + }); + }, "rej"); + }); + return { promise, resolve: res, reject: rej }; + } + __name(createInstrumentedDeferredPromise, "createInstrumentedDeferredPromise"); function fetch2(input, init = void 0) { webidl.argumentLengthCheck(arguments, 1, "globalThis.fetch"); - let p = createDeferredPromise(); let requestObject; try { requestObject = new Request(input, init); } catch (e) { - p.reject(e); - return p.promise; - } - const request = requestObject[kState]; - if (requestObject.signal.aborted) { - abortFetch(p, request, null, requestObject.signal.reason); - return p.promise; + return Promise.reject(e); } - const globalObject = request.client.globalObject; - if (globalObject?.constructor?.name === "ServiceWorkerGlobalScope") { - request.serviceWorkers = "none"; - } - let responseObject = null; - let locallyAborted = false; - let controller = null; - addAbortListener( - requestObject.signal, - () => { - locallyAborted = true; - assert(controller != null); - controller.abort(requestObject.signal.reason); - const realResponse = responseObject?.deref(); - abortFetch(p, request, realResponse, requestObject.signal.reason); + return ifSubscribersRunStores(requestObject, input, init, (p) => { + const request = requestObject[kState]; + if (requestObject.signal.aborted) { + abortFetch(p, request, null, requestObject.signal.reason); + return p.promise; } - ); - const processResponse = /* @__PURE__ */ __name((response) => { - if (locallyAborted) { - return; - } - if (response.aborted) { - abortFetch(p, request, responseObject, controller.serializedAbortReason); - return; - } - if (response.type === "error") { - p.reject(new TypeError("fetch failed", { cause: response.error })); - return; + const globalObject = request.client.globalObject; + if (globalObject?.constructor?.name === "ServiceWorkerGlobalScope") { + request.serviceWorkers = "none"; } - responseObject = new WeakRef(fromInnerResponse(response, "immutable")); - p.resolve(responseObject.deref()); - p = null; - }, "processResponse"); - controller = fetching({ - request, - processResponseEndOfBody: handleFetchDone, - processResponse, - dispatcher: requestObject[kDispatcher] - // undici + let responseObject = null; + let locallyAborted = false; + let controller = null; + addAbortListener( + requestObject.signal, + () => { + locallyAborted = true; + assert(controller != null); + controller.abort(requestObject.signal.reason); + const realResponse = responseObject?.deref(); + abortFetch(p, request, realResponse, requestObject.signal.reason); + } + ); + const processResponse = /* @__PURE__ */ __name((response) => { + if (locallyAborted) { + return; + } + if (response.aborted) { + abortFetch(p, request, responseObject, controller.serializedAbortReason); + return; + } + if (response.type === "error") { + p.reject(new TypeError("fetch failed", { cause: response.error })); + return; + } + responseObject = new WeakRef(fromInnerResponse(response, "immutable")); + p.resolve(responseObject.deref()); + p = null; + }, "processResponse"); + controller = fetching({ + request, + processResponseEndOfBody: handleFetchDone, + processResponse, + dispatcher: requestObject[kDispatcher] + // undici + }); + return p.promise; }); - return p.promise; } __name(fetch2, "fetch"); function finalizeAndReportTiming(response, initiatorType = "other") { @@ -10352,7 +10406,7 @@ var require_fetch = __commonJS({ request.window = request.client?.globalObject?.constructor?.name === "Window" ? request.client : "no-window"; } if (request.origin === "client") { - request.origin = request.client.origin; + request.origin = request.client?.origin; } if (request.policyContainer === "client") { if (request.client != null) { From 60253425b416b3a9a1cc1ab2f6ed5451cf986428 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Wed, 13 Nov 2024 15:26:35 +0100 Subject: [PATCH 02/19] lib: add nsolidTracer EventEmitter So we can subscribe to the `flagsUpdated` event to receive notifications when the tracing flags have changed. Use it in the otel/core.js:register() method. PR-URL: https://github.com/nodesource/nsolid/pull/216 Reviewed-By: Rafael Gonzaga --- lib/internal/nsolid_trace.js | 9 +++++++++ lib/internal/otel/core.js | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/internal/nsolid_trace.js b/lib/internal/nsolid_trace.js index 381d090f61c..e696878108d 100644 --- a/lib/internal/nsolid_trace.js +++ b/lib/internal/nsolid_trace.js @@ -6,6 +6,8 @@ const { RegExp, } = primordials; +const EventEmitter = require('events'); +const binding = internalBinding('nsolid_api'); const { nsolidApi } = require('internal/async_hooks'); const { @@ -66,7 +68,14 @@ function extractSpanContextFromHttpHeaders(context, headers) { return getApi().trace.setSpanContext(context, spanContext); } +const nsolidTracer = new EventEmitter(); +binding.setToggleTracingFn(() => { + nsolidTracer.emit('flagsUpdated'); +}); + + module.exports = { extractSpanContextFromHttpHeaders, generateSpan, + nsolidTracer, }; diff --git a/lib/internal/otel/core.js b/lib/internal/otel/core.js index 9552c00e14d..e6f897c9d11 100644 --- a/lib/internal/otel/core.js +++ b/lib/internal/otel/core.js @@ -26,8 +26,9 @@ function register(api) { // TODO(santigimeno): perform some kind of validation that the api is actually // the OTEL api. api_ = api; - binding.setToggleTracingFn((enable) => { - if (enable) { + const { nsolidTracer } = require('internal/nsolid_trace'); + nsolidTracer.on('flagsUpdated', () => { + if (binding.trace_flags[0]) { enableApi(); } else { disableApi(); From 2b6373691e33f4b1cef66124c5ed0b0fa7f53815 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Wed, 13 Nov 2024 15:30:41 +0100 Subject: [PATCH 03/19] lib: add tracing support for fetch(undici) PR-URL: https://github.com/nodesource/nsolid/pull/216 Reviewed-By: Rafael Gonzaga --- lib/internal/nsolid_diag.js | 95 ++++++++++++++++++- lib/internal/otel/context.js | 4 + .../test-fetch-abort-controller.js | 71 ++++++++++++++ .../addons/nsolid-tracing/test-fetch-abort.js | 87 +++++++++++++++++ test/addons/nsolid-tracing/test-fetch.js | 67 +++++++++++++ test/parallel/test-bootstrap-modules.js | 4 + 6 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 test/addons/nsolid-tracing/test-fetch-abort-controller.js create mode 100644 test/addons/nsolid-tracing/test-fetch-abort.js create mode 100644 test/addons/nsolid-tracing/test-fetch.js diff --git a/lib/internal/nsolid_diag.js b/lib/internal/nsolid_diag.js index 3de44b58ed0..77cd316acf0 100644 --- a/lib/internal/nsolid_diag.js +++ b/lib/internal/nsolid_diag.js @@ -8,23 +8,114 @@ const { } = nsolidApi; const { now } = require('internal/perf/utils'); +const { contextManager } = require('internal/otel/context'); +const { + getApi, +} = require('internal/otel/core'); + +const { + generateSpan, + nsolidTracer, +} = require('internal/nsolid_trace'); const dc = require('diagnostics_channel'); const { kHttpClientAbortCount, kHttpClientCount, + kSpanHttpClient, + kSpanHttpMethod, + kSpanHttpReqUrl, + kSpanHttpStatusCode, } = nsolid_consts; +const undiciFetch = dc.tracingChannel('undici:fetch'); + +let tracingEnabled = false; + +const fetchSubscribeListener = (message, name) => {}; + +function disableTracing() { + undiciFetch.start.unbindStore(); + dc.unsubscribe('tracing:undici:fetch:start', fetchSubscribeListener); +} + +function enableTracing() { + undiciFetch.start.bindStore(contextManager._getALS(), (data) => { + const { req } = data; + const api = getApi(); + const tracer = api.trace.getTracer('http'); + const span = tracer.startSpan(`HTTP ${req.method}`, + { internal: true, + kind: api.SpanKind.CLIENT, + type: kSpanHttpClient }); + span._pushSpanDataString(kSpanHttpMethod, req.method); + span._pushSpanDataString(kSpanHttpReqUrl, req.url); + const { spanId, traceId } = span.spanContext(); + if (span._isSampled()) { + req.headers.append('traceparent', `00-${traceId}-${spanId}-01`); + } else { + req.headers.append('traceparent', `00-${traceId}-${spanId}-00`); + } + + return api.trace.setSpan(api.context.active(), span); + }); + + dc.subscribe('tracing:undici:fetch:start', fetchSubscribeListener); +} + +nsolidTracer.on('flagsUpdated', () => { + const next = generateSpan(kSpanHttpClient); + if (next && !tracingEnabled) { + enableTracing(); + tracingEnabled = true; + } else if (!next && tracingEnabled) { + disableTracing(); + tracingEnabled = false; + } +}); + dc.subscribe('undici:request:create', ({ request }) => { request[nsolid_tracer_s] = now(); }); -dc.subscribe('undici:request:headers', ({ request }) => { +dc.subscribe('undici:request:headers', ({ request, response }) => { nsolid_counts[kHttpClientCount]++; nsolidApi.pushClientBucket(now() - request[nsolid_tracer_s]); + if (generateSpan(kSpanHttpClient)) { + const api = getApi(); + const span = api.trace.getSpan(api.context.active()); + if (span) { + span._pushSpanDataUint64(kSpanHttpStatusCode, response.statusCode); + if (response.statusCode >= 400) { + span.setStatus({ code: getApi().SpanStatusCode.ERROR }); + } + } + } +}); + +dc.subscribe('undici:request:trailers', ({ request }) => { + if (generateSpan(kSpanHttpClient)) { + const api = getApi(); + const span = api.trace.getSpan(api.context.active()); + if (span) { + span.end(); + } + } }); -dc.subscribe('undici:request:error', () => { +dc.subscribe('undici:request:error', ({ request, error }) => { nsolid_counts[kHttpClientAbortCount]++; + if (generateSpan(kSpanHttpClient)) { + const api = getApi(); + const span = api.trace.getSpan(api.context.active()); + if (span) { + span.recordException(error); + span.setStatus({ + code: getApi().SpanStatusCode.ERROR, + message: error.message, + }); + span.end(); + } + } }); diff --git a/lib/internal/otel/context.js b/lib/internal/otel/context.js index 6115df8bee3..9ab2ed27a37 100644 --- a/lib/internal/otel/context.js +++ b/lib/internal/otel/context.js @@ -194,6 +194,10 @@ class AsyncLocalStorageContextManager extends AbstractAsyncHooksContextManager { this._asyncLocalStorage.disable(); return this; } + + _getALS() { + return this._asyncLocalStorage; + } } const contextManager = new AsyncLocalStorageContextManager(); diff --git a/test/addons/nsolid-tracing/test-fetch-abort-controller.js b/test/addons/nsolid-tracing/test-fetch-abort-controller.js new file mode 100644 index 00000000000..faf70dd378e --- /dev/null +++ b/test/addons/nsolid-tracing/test-fetch-abort-controller.js @@ -0,0 +1,71 @@ +// Flags: --dns-result-order=ipv4first +'use strict'; +const common = require('../../common'); +const assert = require('assert'); +const { checkTracesOnExit } = require('../../common/nsolid-traces'); +const { setupNSolid } = require('./utils'); +const http = require('http'); +const bindingPath = require.resolve(`./build/${common.buildType}/binding`); +const binding = require(bindingPath); + +function setupTracesCheck(port, addresses) { + const expectedTraces = [ + { + attributes: { + 'http.method': 'GET', + 'http.url': `http://localhost:${port}/`, + }, + end_reason: binding.kSpanEndOk, + name: 'HTTP GET', + parentId: '0000000000000000', + thread_id: 0, + kind: binding.kClient, + type: binding.kSpanHttpClient, + events: [ + { + attributes: { + 'exception.type': 'ECONNREFUSED', + }, + name: 'exception', + }, + ], + status: { + code: 2, // ERROR + }, + children: [ + { + attributes: { + 'dns.address': addresses, + 'dns.hostname': 'localhost', + 'dns.op_type': binding.kDnsLookup, + }, + end_reason: binding.kSpanEndOk, + name: 'DNS lookup', + thread_id: 0, + kind: binding.kClient, + type: binding.kSpanDns, + }, + ], + }, + ]; + + checkTracesOnExit(binding, expectedTraces); +} + +setupNSolid(common.mustSucceed(({ addresses }) => { + const controller = new AbortController(); + const signal = controller.signal; + + const server = http.createServer(common.mustNotCall()); + server.listen(0, common.mustSucceed(() => { + const port = server.address().port; + setupTracesCheck(port, addresses); + fetch(`http://localhost:${port}`, + { signal }).catch(common.mustCall((err) => { + assert.strictEqual(err.name, 'AbortError'); + assert.strictEqual(err.message, 'This operation was aborted'); + server.close(); + })); + controller.abort(); + })); +})); diff --git a/test/addons/nsolid-tracing/test-fetch-abort.js b/test/addons/nsolid-tracing/test-fetch-abort.js new file mode 100644 index 00000000000..9578968f11a --- /dev/null +++ b/test/addons/nsolid-tracing/test-fetch-abort.js @@ -0,0 +1,87 @@ +// Flags: --dns-result-order=ipv4first +'use strict'; +const common = require('../../common'); +const assert = require('assert'); +const { checkTracesOnExit } = require('../../common/nsolid-traces'); +const { setupNSolid } = require('./utils'); +const http = require('http'); +const bindingPath = require.resolve(`./build/${common.buildType}/binding`); +const binding = require(bindingPath); + +function setupTracesCheck(port, addresses) { + const expectedTraces = [ + { + attributes: { + 'http.method': 'GET', + 'http.url': `http://localhost:${port}/`, + }, + end_reason: binding.kSpanEndOk, + name: 'HTTP GET', + parentId: '0000000000000000', + thread_id: 0, + kind: binding.kClient, + type: binding.kSpanHttpClient, + events: [ + { + attributes: { + 'exception.message': 'other side closed', + 'exception.type': 'UND_ERR_SOCKET', + }, + name: 'exception', + }, + ], + status: { + code: 2, // ERROR + message: 'other side closed', + }, + children: [ + { + attributes: { + 'dns.address': [{ address: addresses[0].address, + family: addresses[0].family }], + 'dns.hostname': 'localhost', + 'dns.op_type': binding.kDnsLookup, + }, + end_reason: binding.kSpanEndOk, + name: 'DNS lookup', + thread_id: 0, + kind: binding.kClient, + type: binding.kSpanDns, + }, + { + attributes: { + 'http.method': 'GET', + 'http.url': `http://localhost:${port}/`, + }, + end_reason: binding.kSpanEndError, + name: 'HTTP GET', + thread_id: 0, + kind: binding.kServer, + type: binding.kSpanHttpServer, + }, + ], + }, + ]; + + checkTracesOnExit(binding, expectedTraces); +} + +setupNSolid(common.mustSucceed(({ addresses }) => { + const server = http.createServer(common.mustCall((req, res) => { + res.destroy(); + })); + + server.listen(0, common.mustSucceed(() => { + const port = server.address().port; + setupTracesCheck(port, addresses); + fetch(`http://localhost:${port}`).catch(common.mustCall((err) => { + assert.strictEqual(err.name, 'TypeError'); + assert.strictEqual(err.message, 'fetch failed'); + const undiciError = err.cause; + assert.strictEqual(undiciError.name, 'SocketError'); + assert.strictEqual(undiciError.message, 'other side closed'); + assert.strictEqual(undiciError.code, 'UND_ERR_SOCKET'); + server.close(); + })); + })); +})); diff --git a/test/addons/nsolid-tracing/test-fetch.js b/test/addons/nsolid-tracing/test-fetch.js new file mode 100644 index 00000000000..6986795fb4e --- /dev/null +++ b/test/addons/nsolid-tracing/test-fetch.js @@ -0,0 +1,67 @@ +// Flags: --dns-result-order=ipv4first +'use strict'; +const common = require('../../common'); +const { checkTracesOnExit } = require('../../common/nsolid-traces'); +const { setupNSolid } = require('./utils'); +const http = require('http'); +const bindingPath = require.resolve(`./build/${common.buildType}/binding`); +const binding = require(bindingPath); + +function setupTracesCheck(port, addresses) { + const expectedTraces = [ + { + attributes: { + 'http.method': 'GET', + 'http.status_code': 200, + 'http.url': `http://localhost:${port}/`, + }, + end_reason: binding.kSpanEndOk, + name: 'HTTP GET', + parentId: '0000000000000000', + thread_id: 0, + kind: binding.kClient, + type: binding.kSpanHttpClient, + children: [ + { + attributes: { + 'dns.address': [{ address: addresses[0].address, + family: addresses[0].family }], + 'dns.hostname': 'localhost', + 'dns.op_type': binding.kDnsLookup, + }, + end_reason: binding.kSpanEndOk, + name: 'DNS lookup', + thread_id: 0, + kind: binding.kClient, + type: binding.kSpanDns, + }, + { + attributes: { + 'http.method': 'GET', + 'http.status_code': 200, + 'http.status_text': 'OK', + 'http.url': `http://localhost:${port}/`, + }, + end_reason: binding.kSpanEndOk, + name: 'HTTP GET', + thread_id: 0, + kind: binding.kServer, + type: binding.kSpanHttpServer, + }, + ], + }, + ]; + + checkTracesOnExit(binding, expectedTraces); +} + +setupNSolid(common.mustSucceed(({ addresses }) => { + const server = http.createServer(common.mustCall((req, res) => { + res.end(); + })).listen(0, common.mustCall(async () => { + const port = server.address().port; + setupTracesCheck(port, addresses); + await fetch(`http://localhost:${port}`); + server.close(); + })); +})); diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index e3388da5746..82ea63bbd06 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -122,6 +122,10 @@ expected.atRunTime = new Set([ 'NativeModule internal/nsolid_loader', 'NativeModule internal/nsolid_promise_tracking', 'NativeModule internal/nsolid_diag', + 'NativeModule internal/nsolid_trace', + 'NativeModule internal/otel/api', + 'NativeModule internal/otel/context', + 'NativeModule internal/otel/core', ]); if (common.isMainThread) { From 16135f4f28edc89fad62b9992992000387d3bc3a Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 14 Nov 2024 15:23:30 +0100 Subject: [PATCH 04/19] deps: update opentelemetry-cpp to 1.17.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, a couple of fixes in the updater: - Fix OPENTELEMETRY_VERSION extraction. - Use `third_party_release` file to get the `opentelemetry-proto`. PR-URL: https://github.com/nodesource/nsolid/pull/221 Reviewed-By: Juan José Arboleda --- deps/opentelemetry-cpp/.bazelrc | 3 - deps/opentelemetry-cpp/.clang-tidy | 42 + deps/opentelemetry-cpp/.iwyu.imp | 11 +- deps/opentelemetry-cpp/api/BUILD | 20 +- deps/opentelemetry-cpp/api/CMakeLists.txt | 5 - .../baggage/propagation/baggage_propagator.h | 6 + .../common/key_value_iterable_view.h | 5 + .../api/include/opentelemetry/common/macros.h | 31 + .../include/opentelemetry/context/context.h | 3 + .../opentelemetry/context/runtime_context.h | 4 + .../opentelemetry/nostd/function_ref.h | 6 +- .../include/opentelemetry/nostd/string_view.h | 5 +- .../api/include/opentelemetry/nostd/variant.h | 2 +- .../opentelemetry/plugin/dynamic_load.h | 6 +- .../include/opentelemetry/std/shared_ptr.h | 4 +- .../api/include/opentelemetry/std/span.h | 2 + .../include/opentelemetry/std/string_view.h | 2 + .../include/opentelemetry/std/type_traits.h | 2 + .../include/opentelemetry/std/unique_ptr.h | 4 +- .../api/include/opentelemetry/std/utility.h | 2 + .../api/include/opentelemetry/std/variant.h | 2 + .../api/include/opentelemetry/trace/noop.h | 10 +- .../include/opentelemetry/trace/provider.h | 4 +- .../api/include/opentelemetry/trace/scope.h | 4 +- .../trace/semantic_conventions.h | 1092 +++++++++++++---- .../opentelemetry/trace/span_context.h | 2 + .../include/opentelemetry/trace/trace_state.h | 5 +- .../api/include/opentelemetry/version.h | 4 +- .../api/test/baggage/baggage_benchmark.cc | 11 +- .../api/test/baggage/baggage_test.cc | 43 +- .../propagation/baggage_propagator_test.cc | 17 +- .../api/test/common/kv_properties_test.cc | 9 +- .../api/test/common/spinlock_benchmark.cc | 17 +- .../api/test/common/string_util_test.cc | 6 +- .../api/test/context/context_test.cc | 17 +- .../propagation/composite_propagator_test.cc | 36 +- .../api/test/context/runtime_context_test.cc | 19 +- .../api/test/core/timestamp_test.cc | 6 +- .../api/test/core/version_test.cc | 6 +- .../api/test/logs/logger_benchmark.cc | 43 +- .../api/test/logs/logger_test.cc | 19 +- .../api/test/logs/provider_test.cc | 9 +- .../api/test/metrics/meter_provider_test.cc | 3 +- .../test/metrics/noop_sync_instrument_test.cc | 7 + .../api/test/nostd/shared_ptr_test.cc | 20 +- .../api/test/nostd/span_test.cc | 8 +- .../api/test/nostd/string_view_test.cc | 7 +- .../api/test/nostd/unique_ptr_test.cc | 18 +- .../api/test/nostd/utility_test.cc | 6 +- .../api/test/plugin/dynamic_load_test.cc | 6 +- .../api/test/singleton/component_a.cc | 5 +- .../api/test/singleton/component_b.cc | 5 +- .../api/test/singleton/component_c.cc | 5 +- .../api/test/singleton/component_d.cc | 5 +- .../api/test/singleton/component_e.cc | 5 +- .../api/test/singleton/component_f.cc | 5 +- .../api/test/singleton/component_g.cc | 5 +- .../api/test/singleton/component_h.cc | 5 +- .../api/test/singleton/singleton_test.cc | 10 +- .../trace/key_value_iterable_view_test.cc | 11 +- .../api/test/trace/noop_test.cc | 23 +- .../trace/propagation/b3_propagation_test.cc | 30 +- .../test/trace/propagation/detail/hex_test.cc | 9 +- .../propagation/http_text_format_test.cc | 34 +- .../propagation/jaeger_propagation_test.cc | 34 +- .../api/test/trace/provider_test.cc | 8 +- .../api/test/trace/scope_test.cc | 12 +- .../api/test/trace/span_benchmark.cc | 17 +- .../api/test/trace/span_id_benchmark.cc | 5 +- .../api/test/trace/trace_flags_test.cc | 7 +- .../api/test/trace/trace_state_test.cc | 11 +- .../api/test/trace/tracer_test.cc | 9 +- .../elasticsearch/es_log_record_exporter.h | 19 +- .../elasticsearch/es_log_recordable.h | 6 +- .../src/es_log_record_exporter.cc | 9 +- .../elasticsearch/src/es_log_recordable.cc | 6 +- .../opentelemetry/exporters/etw/etw_fields.h | 5 +- .../opentelemetry/exporters/etw/etw_tracer.h | 34 +- deps/opentelemetry-cpp/exporters/memory/BUILD | 78 +- .../exporters/memory/CMakeLists.txt | 38 + .../exporters/memory/in_memory_metric_data.h | 72 ++ .../in_memory_metric_exporter_factory.h | 44 + .../exporters/memory/in_memory_span_data.h | 8 +- .../memory/in_memory_span_exporter.h | 11 +- .../memory/src/in_memory_metric_data.cc | 54 + .../src/in_memory_metric_exporter_factory.cc | 93 ++ .../memory/test/in_memory_metric_data_test.cc | 55 + .../test/in_memory_metric_exporter_test.cc | 60 + .../memory/test/in_memory_span_data_test.cc | 1 - .../exporters/ostream/common_utils.h | 2 +- .../exporters/ostream/log_record_exporter.h | 4 +- .../exporters/ostream/metric_exporter.h | 2 +- .../exporters/ostream/span_exporter.h | 2 +- .../ostream/src/log_record_exporter.cc | 10 +- .../exporters/ostream/src/metric_exporter.cc | 2 +- .../exporters/ostream/src/span_exporter.cc | 9 +- .../ostream/test/ostream_log_test.cc | 60 +- .../ostream/test/ostream_span_test.cc | 2 +- .../exporters/otlp/otlp_environment.h | 14 +- .../exporters/otlp/otlp_file_client.h | 9 +- .../exporters/otlp/otlp_file_exporter.h | 13 +- .../otlp/otlp_file_exporter_factory.h | 1 + .../otlp/otlp_file_log_record_exporter.h | 14 +- .../otlp_file_log_record_exporter_factory.h | 1 + .../otlp/otlp_file_metric_exporter.h | 14 +- .../otlp/otlp_file_metric_exporter_factory.h | 1 + .../otlp/otlp_grpc_metric_exporter_factory.h | 2 + .../opentelemetry/exporters/otlp/otlp_http.h | 3 +- .../exporters/otlp/otlp_http_client.h | 19 +- .../exporters/otlp/otlp_http_exporter.h | 17 +- .../otlp/otlp_http_exporter_factory.h | 1 + .../otlp/otlp_http_exporter_options.h | 8 +- .../otlp/otlp_http_log_record_exporter.h | 15 +- .../otlp_http_log_record_exporter_factory.h | 5 +- .../otlp_http_log_record_exporter_options.h | 8 +- .../otlp/otlp_http_metric_exporter.h | 14 +- .../otlp/otlp_http_metric_exporter_factory.h | 5 +- .../otlp/otlp_http_metric_exporter_options.h | 8 +- .../exporters/otlp/otlp_metric_utils.h | 35 +- .../otlp/otlp_populate_attribute_utils.h | 31 +- .../exporters/otlp/otlp_recordable.h | 22 +- .../exporters/otlp/otlp_recordable_utils.h | 36 +- .../exporters/otlp/src/otlp_environment.cc | 17 +- .../exporters/otlp/src/otlp_file_client.cc | 166 +-- .../exporters/otlp/src/otlp_file_exporter.cc | 25 +- .../otlp/src/otlp_file_log_record_exporter.cc | 24 +- .../otlp/src/otlp_file_metric_exporter.cc | 25 +- .../src/otlp_file_metric_exporter_options.cc | 3 +- .../exporters/otlp/src/otlp_grpc_client.cc | 15 +- .../src/otlp_grpc_metric_exporter_options.cc | 3 +- .../exporters/otlp/src/otlp_http_client.cc | 100 +- .../exporters/otlp/src/otlp_http_exporter.cc | 32 +- .../otlp/src/otlp_http_exporter_options.cc | 38 +- .../otlp/src/otlp_http_log_record_exporter.cc | 32 +- .../otlp_http_log_record_exporter_options.cc | 38 +- .../otlp/src/otlp_http_metric_exporter.cc | 30 +- .../src/otlp_http_metric_exporter_options.cc | 41 +- .../exporters/otlp/src/otlp_log_recordable.cc | 19 +- .../exporters/otlp/src/otlp_metric_utils.cc | 86 +- .../otlp/src/otlp_populate_attribute_utils.cc | 37 +- .../exporters/otlp/src/otlp_recordable.cc | 30 +- .../otlp/src/otlp_recordable_utils.cc | 43 +- .../otlp/test/otlp_file_exporter_test.cc | 24 +- .../otlp_file_log_record_exporter_test.cc | 6 +- .../test/otlp_file_metric_exporter_test.cc | 18 +- .../otlp_grpc_log_record_exporter_test.cc | 7 - .../otlp/test/otlp_http_exporter_test.cc | 215 ++-- .../otlp_http_log_record_exporter_test.cc | 363 +++--- .../test/otlp_http_metric_exporter_test.cc | 265 ++-- .../test/otlp_metrics_serialization_test.cc | 6 +- .../otlp/test/otlp_recordable_test.cc | 12 +- .../prometheus/src/exporter_utils.cc | 14 +- .../prometheus/test/collector_test.cc | 22 +- .../prometheus/test/exporter_test.cc | 1 - .../prometheus/test/exporter_utils_test.cc | 7 +- .../exporters/zipkin/recordable.h | 14 + .../exporters/zipkin/zipkin_exporter.h | 18 +- .../zipkin/zipkin_exporter_factory.h | 1 + .../exporters/zipkin/src/recordable.cc | 27 +- .../exporters/zipkin/src/zipkin_exporter.cc | 30 +- .../zipkin/src/zipkin_exporter_factory.cc | 2 + .../zipkin/test/zipkin_exporter_test.cc | 3 +- .../ext/http/client/curl/http_client_curl.h | 21 +- .../http/client/curl/http_operation_curl.h | 3 +- .../ext/http/client/http_client.h | 10 +- .../ext/http/common/url_parser.h | 41 +- deps/opentelemetry-cpp/ext/src/dll/dllmain.cc | 2 +- .../src/http/client/curl/http_client_curl.cc | 35 +- .../client/curl/http_client_factory_curl.cc | 2 + .../http/client/curl/http_operation_curl.cc | 69 +- .../ext/test/http/curl_http_test.cc | 39 +- .../ext/test/http/url_parser_test.cc | 64 +- .../ext/test/w3c_tracecontext_test/main.cc | 35 +- deps/opentelemetry-cpp/otlp-http-exporter.gyp | 1 + .../sdk/common/attribute_utils.h | 8 +- .../sdk/common/attributemap_hash.h | 18 +- .../sdk/common/circular_buffer.h | 4 +- .../sdk/common/circular_buffer_range.h | 3 +- .../sdk/logs/event_logger_provider_factory.h | 9 - .../opentelemetry/sdk/logs/logger_context.h | 2 +- .../opentelemetry/sdk/logs/logger_provider.h | 8 +- .../sdk/logs/logger_provider_factory.h | 32 - .../metrics/aggregation/default_aggregation.h | 2 - .../sdk/metrics/data/metric_data.h | 2 +- .../sdk/metrics/data/point_data.h | 14 - .../sdk/metrics/export/metric_producer.h | 38 +- .../opentelemetry/sdk/metrics/instruments.h | 4 +- .../opentelemetry/sdk/metrics/meter_context.h | 4 +- .../sdk/metrics/meter_provider.h | 4 +- .../sdk/metrics/meter_provider_factory.h | 26 - .../sdk/metrics/observer_result.h | 2 + .../sdk/metrics/state/attributes_hashmap.h | 13 +- .../sdk/metrics/state/metric_collector.h | 2 +- .../sdk/metrics/state/multi_metric_storage.h | 16 +- .../metrics/state/temporal_metric_storage.h | 2 +- .../sdk/metrics/sync_instruments.h | 13 +- .../sdk/metrics/view/attributes_processor.h | 4 +- .../sdk/metrics/view/view_registry.h | 6 +- .../sdk/resource/semantic_conventions.h | 1092 +++++++++++++---- .../opentelemetry/sdk/trace/samplers/parent.h | 2 +- .../sdk/trace/samplers/parent_factory.h | 2 +- .../sdk/trace/simple_processor.h | 3 + .../opentelemetry/sdk/trace/span_data.h | 8 +- .../include/opentelemetry/sdk/trace/tracer.h | 2 - .../opentelemetry/sdk/trace/tracer_context.h | 2 +- .../opentelemetry/sdk/trace/tracer_provider.h | 5 +- .../sdk/trace/tracer_provider_factory.h | 64 - .../opentelemetry/sdk/version/version.h | 2 +- .../sdk/src/common/base64.cc | 7 +- .../sdk/src/common/global_log_handler.cc | 2 +- .../sdk/src/common/random.cc | 9 +- .../src/logs/batch_log_record_processor.cc | 2 + .../sdk/src/logs/event_logger.cc | 2 +- .../src/logs/event_logger_provider_factory.cc | 11 - deps/opentelemetry-cpp/sdk/src/logs/logger.cc | 3 +- .../sdk/src/logs/logger_context.cc | 2 +- .../sdk/src/logs/logger_provider.cc | 10 +- .../sdk/src/logs/logger_provider_factory.cc | 46 - .../sdk/src/logs/readable_log_record.cc | 1 - .../aggregation/histogram_aggregation.cc | 4 +- .../aggregation/lastvalue_aggregation.cc | 22 +- .../metrics/aggregation/sum_aggregation.cc | 5 +- .../sdk/src/metrics/async_instruments.cc | 4 +- .../sdk/src/metrics/exemplar/reservoir.cc | 10 +- .../periodic_exporting_metric_reader.cc | 82 +- .../sdk/src/metrics/meter.cc | 5 +- .../sdk/src/metrics/meter_context.cc | 41 +- .../sdk/src/metrics/meter_provider.cc | 6 +- .../sdk/src/metrics/meter_provider_factory.cc | 36 - .../sdk/src/metrics/metric_reader.cc | 12 +- .../sdk/src/metrics/state/metric_collector.cc | 13 +- .../src/metrics/state/observable_registry.cc | 1 - .../src/metrics/state/sync_metric_storage.cc | 2 +- .../metrics/state/temporal_metric_storage.cc | 4 +- .../sdk/src/metrics/sync_instruments.cc | 12 +- .../sdk/src/metrics/view/view_factory.cc | 5 +- .../sdk/src/trace/batch_span_processor.cc | 7 +- .../sdk/src/trace/samplers/parent.cc | 2 +- .../sdk/src/trace/samplers/parent_factory.cc | 7 +- deps/opentelemetry-cpp/sdk/src/trace/span.cc | 2 +- .../opentelemetry-cpp/sdk/src/trace/tracer.cc | 4 +- .../sdk/src/trace/tracer_context.cc | 2 +- .../sdk/src/trace/tracer_provider.cc | 6 +- .../sdk/src/trace/tracer_provider_factory.cc | 86 -- .../sdk/src/version/version.cc | 8 +- .../sdk/test/common/attribute_utils_test.cc | 10 +- .../common/attributemap_hash_benchmark.cc | 2 + .../test/common/circular_buffer_benchmark.cc | 10 +- .../test/common/circular_buffer_range_test.cc | 6 +- .../sdk/test/common/circular_buffer_test.cc | 16 +- .../sdk/test/common/empty_attributes_test.cc | 2 +- .../sdk/test/common/env_var_test.cc | 7 +- .../fast_random_number_generator_test.cc | 8 +- .../sdk/test/common/global_log_handle_test.cc | 7 +- .../sdk/test/common/random_benchmark.cc | 6 +- .../sdk/test/common/random_fork_test.cc | 4 +- .../sdk/test/common/random_test.cc | 36 +- .../instrumentationscope_test.cc | 15 +- .../logs/batch_log_record_processor_test.cc | 36 +- .../sdk/test/logs/log_record_test.cc | 22 +- .../sdk/test/logs/logger_provider_sdk_test.cc | 24 +- .../sdk/test/logs/logger_sdk_test.cc | 27 +- .../logs/simple_log_record_processor_test.cc | 25 +- deps/opentelemetry-cpp/sdk/test/metrics/BUILD | 303 +---- .../sdk/test/metrics/aggregation_test.cc | 10 +- .../test/metrics/async_instruments_test.cc | 17 +- .../test/metrics/async_metric_storage_test.cc | 43 +- .../metrics/attributes_hashmap_benchmark.cc | 17 +- .../test/metrics/attributes_hashmap_test.cc | 106 +- .../metrics/attributes_processor_benchmark.cc | 5 + .../test/metrics/attributes_processor_test.cc | 11 +- ...exponential_histogram_indexer_benchmark.cc | 5 +- ...ase2_exponential_histogram_indexer_test.cc | 6 +- .../test/metrics/cardinality_limit_test.cc | 76 +- .../metrics/circular_buffer_counter_test.cc | 5 +- .../sdk/test/metrics/common.cc | 4 +- .../sdk/test/metrics/common.h | 9 +- .../histogram_aggregation_benchmark.cc | 21 +- .../metrics/histogram_aggregation_test.cc | 21 +- .../sdk/test/metrics/histogram_test.cc | 142 ++- .../instrument_metadata_validator_test.cc | 12 +- .../test/metrics/measurements_benchmark.cc | 29 +- .../test/metrics/meter_provider_sdk_test.cc | 10 +- .../sdk/test/metrics/meter_test.cc | 27 +- .../sdk/test/metrics/metric_reader_test.cc | 12 +- .../test/metrics/multi_metric_storage_test.cc | 15 +- .../test/metrics/observable_registry_test.cc | 5 +- .../sdk/test/metrics/observer_result_test.cc | 12 +- .../periodic_exporting_metric_reader_test.cc | 62 +- .../test/metrics/sum_aggregation_benchmark.cc | 24 +- .../sdk/test/metrics/sum_aggregation_test.cc | 26 +- .../sdk/test/metrics/sync_instruments_test.cc | 19 +- .../sync_metric_storage_counter_test.cc | 28 +- .../sync_metric_storage_histogram_test.cc | 29 +- ...ync_metric_storage_up_down_counter_test.cc | 41 +- .../sdk/test/metrics/view_registry_test.cc | 15 +- .../sdk/test/resource/resource_test.cc | 29 +- .../sdk/test/trace/always_off_sampler_test.cc | 12 + .../sdk/test/trace/always_on_sampler_test.cc | 18 +- .../test/trace/batch_span_processor_test.cc | 37 +- .../sdk/test/trace/parent_sampler_test.cc | 18 +- .../sdk/test/trace/sampler_benchmark.cc | 24 +- .../sdk/test/trace/simple_processor_test.cc | 16 +- .../sdk/test/trace/span_data_test.cc | 37 +- .../test/trace/trace_id_ratio_sampler_test.cc | 20 +- .../sdk/test/trace/tracer_provider_test.cc | 23 +- .../sdk/test/trace/tracer_test.cc | 48 +- .../v1experimental/pprofextended.proto | 4 +- .../profiles/v1experimental/profiles.proto | 2 +- deps/opentelemetry-cpp/third_party_release | 25 + .../dep_updaters/update-opentelemetry-cpp.sh | 14 +- 311 files changed, 5779 insertions(+), 2923 deletions(-) create mode 100644 deps/opentelemetry-cpp/.clang-tidy create mode 100644 deps/opentelemetry-cpp/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h create mode 100644 deps/opentelemetry-cpp/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h create mode 100644 deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_data.cc create mode 100644 deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_exporter_factory.cc create mode 100644 deps/opentelemetry-cpp/exporters/memory/test/in_memory_metric_data_test.cc create mode 100644 deps/opentelemetry-cpp/exporters/memory/test/in_memory_metric_exporter_test.cc create mode 100644 deps/opentelemetry-cpp/third_party_release diff --git a/deps/opentelemetry-cpp/.bazelrc b/deps/opentelemetry-cpp/.bazelrc index fc170b0e8bd..f1693476474 100644 --- a/deps/opentelemetry-cpp/.bazelrc +++ b/deps/opentelemetry-cpp/.bazelrc @@ -4,9 +4,6 @@ # bazel configurations for running tests under sanitizers. # Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc -# TODO: Remove once support is added, avoid MODULE.bazel creation for now -common --enable_bzlmod=false - # Enable automatic configs based on platform common --enable_platform_specific_config diff --git a/deps/opentelemetry-cpp/.clang-tidy b/deps/opentelemetry-cpp/.clang-tidy new file mode 100644 index 00000000000..db61b810c99 --- /dev/null +++ b/deps/opentelemetry-cpp/.clang-tidy @@ -0,0 +1,42 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +Checks: > + -*, + performance-*, + portability-*, + abseil-*, + -abseil-string-find-str-contains, + bugprone-*, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-inc-dec-in-conditions, + -bugprone-narrowing-conversions, + -bugprone-unchecked-optional-access, + -bugprone-unhandled-exception-at-new, + -bugprone-unused-local-non-trivial-variable, + google-*, + -google-build-using-namespace, + -google-default-arguments, + -google-explicit-constructor, + -google-readability-avoid-underscore-in-googletest-name, + -google-readability-braces-around-statements, + -google-readability-namespace-comments, + -google-readability-todo, + -google-runtime-references, + misc-*, + -misc-const-correctness, + -misc-include-cleaner, + -misc-non-private-member-variables-in-classes, + -misc-unused-alias-decls, + -misc-use-anonymous-namespace, + cppcoreguidelines-*, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-avoid-do-while, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-init-variables, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-pro-* \ No newline at end of file diff --git a/deps/opentelemetry-cpp/.iwyu.imp b/deps/opentelemetry-cpp/.iwyu.imp index 53fddd24aac..6529a924587 100644 --- a/deps/opentelemetry-cpp/.iwyu.imp +++ b/deps/opentelemetry-cpp/.iwyu.imp @@ -7,7 +7,16 @@ # Work around for C++ STL { "include": ["", "private", "", "public"] }, - # Local opentelemetry-cpp + # Local opentelemetry-cpp style + # We prefer to include for simplicity + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, + + # We prefer to include for simplicity + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, ] diff --git a/deps/opentelemetry-cpp/api/BUILD b/deps/opentelemetry-cpp/api/BUILD index fdfe3ca146f..dfc7d3c6450 100644 --- a/deps/opentelemetry-cpp/api/BUILD +++ b/deps/opentelemetry-cpp/api/BUILD @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag") package(default_visibility = ["//visibility:public"]) @@ -35,6 +35,9 @@ cc_library( ":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"], ":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"], "//conditions:default": [], + }) + select({ + ":abi_version_no_1": ["OPENTELEMETRY_ABI_VERSION_NO=1"], + ":abi_version_no_2": ["OPENTELEMETRY_ABI_VERSION_NO=2"], }), strip_include_prefix = "include", tags = ["api"], @@ -61,3 +64,18 @@ bool_flag( build_setting_default = False, deprecation = "The value of this flag is ignored. Bazel builds always depend on Abseil for its pre-adopted `std::` types. You should remove this flag from your build command.", ) + +int_flag( + name = "abi_version_no", + build_setting_default = 1, +) + +config_setting( + name = "abi_version_no_1", + flag_values = {":abi_version_no": "1"}, +) + +config_setting( + name = "abi_version_no_2", + flag_values = {":abi_version_no": "2"}, +) diff --git a/deps/opentelemetry-cpp/api/CMakeLists.txt b/deps/opentelemetry-cpp/api/CMakeLists.txt index e07275efed5..78e97ad0297 100644 --- a/deps/opentelemetry-cpp/api/CMakeLists.txt +++ b/deps/opentelemetry-cpp/api/CMakeLists.txt @@ -35,11 +35,6 @@ if(WITH_NO_DEPRECATED_CODE) INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE) endif() -if(WITH_DEPRECATED_SDK_FACTORY) - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_DEPRECATED_SDK_FACTORY) -endif() - if(WITH_ABSEIL) target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL) target_link_libraries( diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/baggage/propagation/baggage_propagator.h b/deps/opentelemetry-cpp/api/include/opentelemetry/baggage/propagation/baggage_propagator.h index 6de32882c01..d75409ed609 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/baggage/propagation/baggage_propagator.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/baggage/propagation/baggage_propagator.h @@ -3,9 +3,15 @@ #pragma once +#include +#include + #include "opentelemetry/baggage/baggage.h" #include "opentelemetry/baggage/baggage_context.h" +#include "opentelemetry/context/context.h" #include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/common/key_value_iterable_view.h b/deps/opentelemetry-cpp/api/include/opentelemetry/common/key_value_iterable_view.h index fb1a6ea019f..e22fb6f06f5 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/common/key_value_iterable_view.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/common/key_value_iterable_view.h @@ -3,9 +3,14 @@ #pragma once +#include +#include #include +#include #include +#include +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/span.h" diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/common/macros.h b/deps/opentelemetry-cpp/api/include/opentelemetry/common/macros.h index b4a270084d2..b74c1048fc9 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/common/macros.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/common/macros.h @@ -387,6 +387,37 @@ point. #endif +// OPENTELEMETRY_HAVE_EXCEPTIONS +// +// Checks whether the compiler both supports and enables exceptions. Many +// compilers support a "no exceptions" mode that disables exceptions. +// +// Generally, when OPENTELEMETRY_HAVE_EXCEPTIONS is not defined: +// +// * Code using `throw` and `try` may not compile. +// * The `noexcept` specifier will still compile and behave as normal. +// * The `noexcept` operator may still return `false`. +// +// For further details, consult the compiler's documentation. +#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS +# if defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__) < 306 +// Clang < 3.6 +// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro +# if defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +# endif // defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# elif OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +// Handle remaining special cases and default to exceptions being supported. +# elif !(defined(__GNUC__) && !defined(__EXCEPTIONS) && !defined(__cpp_exceptions)) && \ + !(defined(_MSC_VER) && !defined(_CPPUNWIND)) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +# endif +#endif +#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS +# define OPENTELEMETRY_HAVE_EXCEPTIONS 0 +#endif + /* OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND indicates that a resource owned by a function parameter or implicit object parameter is retained by the return value of the diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/context/context.h b/deps/opentelemetry-cpp/api/include/opentelemetry/context/context.h index cf5c9cd319e..620ca51c8b3 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/context/context.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/context/context.h @@ -4,9 +4,12 @@ #pragma once #include +#include + #include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/context/runtime_context.h b/deps/opentelemetry-cpp/api/include/opentelemetry/context/runtime_context.h index cccc71e32f0..73d4dcd9088 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/context/runtime_context.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/context/runtime_context.h @@ -3,8 +3,12 @@ #pragma once +#include +#include + #include "opentelemetry/common/macros.h" #include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/function_ref.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/function_ref.h index 1064c966d7b..6f0c2dd330b 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/function_ref.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/function_ref.h @@ -3,8 +3,10 @@ #pragma once -#include +#include +#include // IWYU pragma: keep #include +#include #include "opentelemetry/version.h" @@ -12,7 +14,7 @@ OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { template -class function_ref; +class function_ref; // IWYU pragma: keep /** * Non-owning function reference that can be used as a more performant diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/string_view.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/string_view.h index 5ee86dce23b..f0e5bd9e2ac 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/string_view.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/string_view.h @@ -12,13 +12,14 @@ #if !defined(OPENTELEMETRY_HAVE_STD_STRING_VIEW) # include -# include # include +# include # include # include # include +# include +# include -# include "opentelemetry/common/macros.h" # include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/variant.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/variant.h index d0b2d960015..6f3837c5883 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/variant.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/variant.h @@ -54,7 +54,7 @@ OPENTELEMETRY_END_NAMESPACE # ifdef HAVE_ABSEIL # include "absl/types/variant.h" # else -# include "./internal/absl/types/variant.h" +# include "opentelemetry/nostd/internal/absl/types/variant.h" # endif # ifdef _MSC_VER diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/plugin/dynamic_load.h b/deps/opentelemetry-cpp/api/include/opentelemetry/plugin/dynamic_load.h index 10b4a34af45..2da27135553 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/plugin/dynamic_load.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/plugin/dynamic_load.h @@ -6,19 +6,19 @@ #include #include +#include "opentelemetry/plugin/factory.h" +#include "opentelemetry/version.h" + #ifdef _WIN32 # include "opentelemetry/plugin/detail/dynamic_load_windows.h" // IWYU pragma: export #else # include "opentelemetry/plugin/detail/dynamic_load_unix.h" // IWYU pragma: export #endif -#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace plugin { -class Factory; - /** * Load an OpenTelemetry implementation as a plugin. * @param plugin the path to the plugin to load diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/std/shared_ptr.h b/deps/opentelemetry-cpp/api/include/opentelemetry/std/shared_ptr.h index b1b99bd36c9..8b855b08c61 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/std/shared_ptr.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/std/shared_ptr.h @@ -3,7 +3,9 @@ #pragma once -#include +// IWYU pragma: private, include "opentelemetry/nostd/shared_ptr.h" + +#include // IWYU pragma: export #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/std/span.h b/deps/opentelemetry-cpp/api/include/opentelemetry/std/span.h index 1160d54fbed..5d20e0227f9 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/std/span.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/std/span.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/span.h" + #include "opentelemetry/version.h" // Standard library implementation requires at least C++17 compiler. diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/std/string_view.h b/deps/opentelemetry-cpp/api/include/opentelemetry/std/string_view.h index 5295eb4544c..d0f0c081250 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/std/string_view.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/std/string_view.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/string_view.h" + #include #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/std/type_traits.h b/deps/opentelemetry-cpp/api/include/opentelemetry/std/type_traits.h index f26af95b94c..074f7967984 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/std/type_traits.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/std/type_traits.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/type_traits.h" + #include #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/std/unique_ptr.h b/deps/opentelemetry-cpp/api/include/opentelemetry/std/unique_ptr.h index 1d7d9b1fc72..4b25b7c3812 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/std/unique_ptr.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/std/unique_ptr.h @@ -3,7 +3,9 @@ #pragma once -#include +// IWYU pragma: private, include "opentelemetry/nostd/unique_ptr.h" + +#include // IWYU pragma: export #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/std/utility.h b/deps/opentelemetry-cpp/api/include/opentelemetry/std/utility.h index be0f1e5f46b..d1f5614d7c2 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/std/utility.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/std/utility.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/utility.h" + #include #include diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/std/variant.h b/deps/opentelemetry-cpp/api/include/opentelemetry/std/variant.h index 6acdb81e9af..58bc510c5f6 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/std/variant.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/std/variant.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/variant.h" + #include "opentelemetry/version.h" #include diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/noop.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/noop.h index 345c4ba0c9c..fa0c7957df0 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/noop.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/noop.h @@ -7,15 +7,21 @@ // This file is part of the internal implementation of OpenTelemetry. Nothing in this file should be // used directly. Please refer to span.h and tracer.h for documentation on these interfaces. -#include +#include +#include -#include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #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/span_metadata.h" +#include "opentelemetry/trace/span_startoptions.h" #include "opentelemetry/trace/tracer.h" #include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/provider.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/provider.h index d5a52a02f6f..1439b579be8 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/provider.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/provider.h @@ -5,18 +5,16 @@ #include -#include "opentelemetry/common/macros.h" #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/trace/noop.h" +#include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace trace { -class TracerProvider; - /** * Stores the singleton global TracerProvider. */ diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/scope.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/scope.h index 11ded4ab6cd..20c415cc726 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/scope.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/scope.h @@ -3,9 +3,11 @@ #pragma once +#include "opentelemetry/context/context.h" #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_metadata.h" #include "opentelemetry/version.h" @@ -13,8 +15,6 @@ OPENTELEMETRY_BEGIN_NAMESPACE namespace trace { -class Span; - /** * Controls how long a span is active. * diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/semantic_conventions.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/semantic_conventions.h index a9290bff44b..fb26385fbc5 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/semantic_conventions.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/semantic_conventions.h @@ -22,7 +22,7 @@ namespace SemanticConventions /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.26.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.27.0"; /** * Uniquely identifies the framework API revision offered by a version ({@code os.version}) of the @@ -31,6 +31,69 @@ static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.26 */ static constexpr const char *kAndroidOsApiLevel = "android.os.api_level"; +/** + * The provenance filename of the built attestation which directly relates to the build artifact + * filename. This filename SHOULD accompany the artifact at publish time. See the SLSA + * Relationship specification for more information. + */ +static constexpr const char *kArtifactAttestationFilename = "artifact.attestation.filename"; + +/** + * The full hash value (see + * glossary), of the built attestation. Some envelopes in the software attestation space also + * refer to this as the digest. + */ +static constexpr const char *kArtifactAttestationHash = "artifact.attestation.hash"; + +/** + * The id of the build software attestation. + */ +static constexpr const char *kArtifactAttestationId = "artifact.attestation.id"; + +/** + * The human readable file name of the artifact, typically generated during build and release +processes. Often includes the package name and version in the file name. + * + *

Notes: +

  • This file name can also act as the Package Name in cases where the +package ecosystem maps accordingly. Additionally, the artifact can be published for others, +but that is not a guarantee.
+ */ +static constexpr const char *kArtifactFilename = "artifact.filename"; + +/** + * The full hash value (see +glossary), often found in checksum.txt on a release of the artifact and used to verify package +integrity. + * + *

Notes: +

  • The specific algorithm used to create the cryptographic hash value is +not defined. In situations where an artifact has multiple +cryptographic hashes, it is up to the implementer to choose which +hash value to set here; this should be the most secure hash algorithm +that is suitable for the situation and consistent with the +corresponding attestation. The implementer can then provide the other +hash values through an additional set of attribute extensions as they +deem necessary.
+ */ +static constexpr const char *kArtifactHash = "artifact.hash"; + +/** + * The Package URL of the package artifact provides a + * standard way to identify and locate the packaged artifact. + */ +static constexpr const char *kArtifactPurl = "artifact.purl"; + +/** + * The version of the artifact. + */ +static constexpr const char *kArtifactVersion = "artifact.version"; + /** * Rate-limiting result, shows whether the lease was acquired or contains a rejection reason */ @@ -397,6 +460,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 unique identifier of the service request. It's generated by the Azure service and returned + * with the response. + */ +static constexpr const char *kAzServiceRequestId = "az.service_request_id"; + /** * Array of brand name and version separated by a space * @@ -443,6 +512,39 @@ provides. */ static constexpr const char *kBrowserPlatform = "browser.platform"; +/** + * The human readable name of the pipeline within a CI/CD system. + */ +static constexpr const char *kCicdPipelineName = "cicd.pipeline.name"; + +/** + * The unique identifier of a pipeline run within a CI/CD system. + */ +static constexpr const char *kCicdPipelineRunId = "cicd.pipeline.run.id"; + +/** + * The human readable name of a task within a pipeline. Task here most closely aligns with a computing process in a pipeline. + * Other terms for tasks include commands, steps, and procedures. + */ +static constexpr const char *kCicdPipelineTaskName = "cicd.pipeline.task.name"; + +/** + * The unique identifier of a task run within a pipeline. + */ +static constexpr const char *kCicdPipelineTaskRunId = "cicd.pipeline.task.run.id"; + +/** + * The URL of the pipeline run providing the + * complete address in order to locate and identify the pipeline run. + */ +static constexpr const char *kCicdPipelineTaskRunUrlFull = "cicd.pipeline.task.run.url.full"; + +/** + * The type of the task within a pipeline. + */ +static constexpr const char *kCicdPipelineTaskType = "cicd.pipeline.task.type"; + /** * Client address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. @@ -523,7 +625,7 @@ Lambda: The function ARN. Take care not to use the "invoked ARN" directly but replace any alias suffix with -the resolved function version, as the same runtime instance may be invokable with multiple different +the resolved function version, as the same runtime instance may be invocable with multiple different aliases.
  • GCP: The URI of the resource
  • Azure: The identify Docker @@ -688,26 +785,36 @@ static constexpr const char *kContainerName = "container.name"; */ static constexpr const char *kContainerRuntime = "container.runtime"; +/** + * The mode of the CPU + */ +static constexpr const char *kCpuMode = "cpu.mode"; + /** * The name of the connection pool; unique within the instrumented application. In case the - * connection pool implementation doesn't provide a name, instrumentation should use a combination - * of {@code server.address} and {@code server.port} attributes formatted as {@code - * server.address:server.port}. + * connection pool implementation doesn't provide a name, instrumentation SHOULD use a combination + * of parameters that would make the name unique, for example, combining attributes {@code + * server.address}, {@code server.port}, and {@code db.namespace}, formatted as {@code + * server.address:server.port/db.namespace}. Instrumentations that generate connection pool name + * following different patterns SHOULD document it. */ -static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; +static constexpr const char *kDbClientConnectionPoolName = "db.client.connection.pool.name"; /** * The state of a connection in the pool */ -static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; +static constexpr const char *kDbClientConnectionState = "db.client.connection.state"; /** * The name of a collection (table, container) within the database. * *

    Notes: -

    • If the collection name is parsed from the query, it SHOULD match the value provided in -the query and may be qualified with the schema and database name. It is RECOMMENDED to capture the -value as provided by the application without attempting to do any case normalization.
    +
    • It is RECOMMENDED to capture the value as provided by the application without attempting +to do any case normalization. If the collection name is parsed from the query text, it SHOULD be the +first collection name found in the query and it SHOULD match the value provided in the query text +including any schema and database name prefix. For batch operations, if the individual operations +are known to have the same collection name then that collection name SHOULD be used, otherwise +{@code db.collection.name} SHOULD NOT be captured.
    */ static constexpr const char *kDbCollectionName = "db.collection.name"; @@ -725,17 +832,42 @@ provided by the application without attempting to do any case normalization.
  • batch operation. + * + *

    Notes: +

    • Operations are only considered batches when they contain two or more operations, and so + {@code db.operation.batch.size} SHOULD never be {@code 1}.
    + */ +static constexpr const char *kDbOperationBatchSize = "db.operation.batch.size"; + /** * The name of the operation or command being executed. * *

    Notes:

    • It is RECOMMENDED to capture the value as provided by the application without attempting - to do any case normalization.
    +to do any case normalization. If the operation name is parsed from the query text, it SHOULD be the +first operation name found in the query. For batch operations, if the individual operations are +known to have the same operation name then that operation name SHOULD be used prepended by {@code +BATCH}, otherwise {@code db.operation.name} SHOULD be {@code BATCH} or some other database system +specific term if more applicable. */ static constexpr const char *kDbOperationName = "db.operation.name"; /** * The database query being executed. + * + *

    Notes: +

    • For sanitization see Sanitization of {@code +db.query.text}. For batch operations, if the individual operations are known to have the same +query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD +be concatenated with separator {@code ;} or some other database system specific separator if more +applicable. Even though parameterized query text can potentially have sensitive data, by using a +parameterized query the user is giving a strong signal that any sensitive data will be passed as +parameter values, and the benefit to observability of capturing the static part of the query text by +default outweighs the risk.
    */ static constexpr const char *kDbQueryText = "db.query.text"; @@ -817,11 +949,6 @@ static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; */ static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; -/** - * Represents the identifier of an Elasticsearch cluster. - */ -static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; - /** * Represents the human-readable identifier of the node/instance to which a request was routed. */ @@ -832,15 +959,30 @@ static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.n environment (aka deployment tier). * *

    Notes: -

    • {@code deployment.environment} does not affect the uniqueness constraints defined through -the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource +
      • {@code deployment.environment.name} does not affect the uniqueness constraints defined +through the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource attributes. This implies that resources carrying the following attribute combinations MUST be considered to be identifying the same service:
      • {@code service.name=frontend}, {@code -deployment.environment=production}
      • {@code service.name=frontend}, {@code -deployment.environment=staging}.
      • +deployment.environment.name=production}
      • {@code service.name=frontend}, {@code +deployment.environment.name=staging}.
      */ -static constexpr const char *kDeploymentEnvironment = "deployment.environment"; +static constexpr const char *kDeploymentEnvironmentName = "deployment.environment.name"; + +/** + * The id of the deployment. + */ +static constexpr const char *kDeploymentId = "deployment.id"; + +/** + * The name of the deployment. + */ +static constexpr const char *kDeploymentName = "deployment.name"; + +/** + * The status of the deployment. + */ +static constexpr const char *kDeploymentStatus = "deployment.status"; /** * Deprecated use the {@code device.app.lifecycle} event definition including {@code android.state} @@ -853,6 +995,14 @@ static constexpr const char *kDeploymentEnvironment = "deployment.environment"; */ static constexpr const char *kAndroidState = "android.state"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kContainerCpuState = "container.cpu.state"; + /** * Deprecated, use {@code db.collection.name} instead. * @@ -877,6 +1027,14 @@ static constexpr const char *kDbConnectionString = "db.connection_string"; OPENTELEMETRY_DEPRECATED static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; +/** + * Deprecated, use {@code db.namespace} instead. + * + * @deprecated Deprecated, use `db.namespace` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; + /** * Deprecated, no general replacement at this time. For Elasticsearch, use {@code * db.elasticsearch.node.name} instead. @@ -961,21 +1119,85 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbUser = "db.user"; /** - * Deprecated, use {@code db.client.connections.pool.name} instead. + * Deprecated, use {@code db.client.connection.pool.name} instead. + * + * @deprecated Deprecated, use `db.client.connection.pool.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; + +/** + * Deprecated, use {@code db.client.connection.state} instead. + * + * @deprecated Deprecated, use `db.client.connection.state` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; + +/** + * Deprecated, use {@code db.client.connection.pool.name} instead. * - * @deprecated Deprecated, use `db.client.connections.pool.name` instead. + * @deprecated Deprecated, use `db.client.connection.pool.name` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kPoolName = "pool.name"; /** - * Deprecated, use {@code db.client.connections.state} instead. + * Deprecated, use {@code db.client.connection.state} instead. * - * @deprecated Deprecated, use `db.client.connections.state` instead. + * @deprecated Deprecated, use `db.client.connection.state` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kState = "state"; +/** + * 'Deprecated, use {@code deployment.environment.name} instead.' + * + * @deprecated 'Deprecated, use `deployment.environment.name` instead.'. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDeploymentEnvironment = "deployment.environment"; + +/** + * Deprecated, use {@code user.id} instead. + * + * @deprecated Deprecated, use `user.id` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserId = "enduser.id"; + +/** + * Deprecated, use {@code user.roles} instead. + * + * @deprecated Deprecated, use `user.roles` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserRole = "enduser.role"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserScope = "enduser.scope"; + +/** + * Deprecated, use {@code gen_ai.usage.output_tokens} instead. + * + * @deprecated Deprecated, use `gen_ai.usage.output_tokens` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; + +/** + * Deprecated, use {@code gen_ai.usage.input_tokens} instead. + * + * @deprecated Deprecated, use `gen_ai.usage.input_tokens` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; + /** * Deprecated, use {@code client.address} instead. * @@ -1107,6 +1329,41 @@ static constexpr const char *kHttpUserAgent = "http.user_agent"; OPENTELEMETRY_DEPRECATED static constexpr const char *kIosState = "ios.state"; +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; + +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingEventhubsConsumerGroup = + "messaging.eventhubs.consumer.group"; + +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; + /** * Deprecated, use {@code messaging.destination.partition.id} instead. * @@ -1116,6 +1373,14 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingKafkaDestinationPartition = "messaging.kafka.destination.partition"; +/** + * Deprecated, use {@code messaging.kafka.offset} instead. + * + * @deprecated Deprecated, use `messaging.kafka.offset` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; + /** * Deprecated, use {@code messaging.operation.type} instead. * @@ -1124,6 +1389,23 @@ static constexpr const char *kMessagingKafkaDestinationPartition = OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingOperation = "messaging.operation"; +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; + +/** + * Deprecated, use {@code messaging.servicebus.destination.subscription_name} instead. + * + * @deprecated Deprecated, use `messaging.servicebus.destination.subscription_name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingServicebusDestinationSubscriptionName = + "messaging.servicebus.destination.subscription_name"; + /** * Deprecated, use {@code network.local.address}. * @@ -1247,21 +1529,29 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kNetTransport = "net.transport"; /** - * None * - * @deprecated None. + * + * @deprecated . */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryName = "otel.library.name"; /** - * None * - * @deprecated None. + * + * @deprecated . */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryVersion = "otel.library.version"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kProcessCpuState = "process.cpu.state"; + /** * Deprecated, use {@code rpc.message.compressed_size} instead. * @@ -1294,6 +1584,14 @@ static constexpr const char *kMessageType = "message.type"; OPENTELEMETRY_DEPRECATED static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kSystemCpuState = "system.cpu.state"; + /** * Deprecated, use {@code system.process.status} instead. * @@ -1302,6 +1600,14 @@ static constexpr const char *kMessageUncompressedSize = "message.uncompressed_si OPENTELEMETRY_DEPRECATED static constexpr const char *kSystemProcessesStatus = "system.processes.status"; +/** + * Deprecated, use {@code server.address} instead. + * + * @deprecated Deprecated, use `server.address` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kTlsClientServerName = "tls.client.server_name"; + /** * Destination address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. @@ -1380,29 +1686,6 @@ static constexpr const char *kDiskIoDirection = "disk.io.direction"; */ static constexpr const char *kDnsQuestionName = "dns.question.name"; -/** - * Username or client_id extracted from the access token or Authorization header in the inbound - * request from outside the system. - */ -static constexpr const char *kEnduserId = "enduser.id"; - -/** - * Actual/assumed role the client is making the request under extracted from token or application - * security context. - */ -static constexpr const char *kEnduserRole = "enduser.role"; - -/** - * 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 *kEnduserScope = "enduser.scope"; - /** * Describes a class of error the operation ended with. * @@ -1428,9 +1711,9 @@ static constexpr const char *kErrorType = "error.type"; * *

      Notes:

      • Event names are subject to the same rules as attribute - names. Notably, event names are namespaced to avoid collisions and provide a clean separation - of semantics for events in separate domains like browser, mobile, and kubernetes.
      + href="/docs/general/attribute-naming.md">attribute names. Notably, event names are namespaced + to avoid collisions and provide a clean separation of semantics for events in separate domains like + browser, mobile, and kubernetes.
    */ static constexpr const char *kEventName = "event.name"; @@ -1665,6 +1948,16 @@ static constexpr const char *kFilePath = "file.path"; */ static constexpr const char *kFileSize = "file.size"; +/** + * Identifies the Google Cloud service for which the official client library is intended. + * + *

    Notes: +

    • Intended to be a stable identifier for Google Cloud client libraries that is uniform + across implementation languages. The value should be derived from the canonical service domain for + the service; for example, 'foo.googleapis.com' should result in a value of 'foo'.
    + */ +static constexpr const char *kGcpClientService = "gcp.client.service"; + /** * The name of the Cloud Run execution being run for the @@ -1697,7 +1990,7 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; /** - * The full response received from the LLM. + * The full response received from the GenAI model. * *

    Notes:

    */ static constexpr const char *kDbOperationName = "db.operation.name"; /** * The database query being executed. + * + *

    Notes: +

    • For sanitization see Sanitization of {@code +db.query.text}. For batch operations, if the individual operations are known to have the same +query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD +be concatenated with separator {@code ;} or some other database system specific separator if more +applicable. Even though parameterized query text can potentially have sensitive data, by using a +parameterized query the user is giving a strong signal that any sensitive data will be passed as +parameter values, and the benefit to observability of capturing the static part of the query text by +default outweighs the risk.
    */ static constexpr const char *kDbQueryText = "db.query.text"; @@ -819,11 +951,6 @@ static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; */ static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; -/** - * Represents the identifier of an Elasticsearch cluster. - */ -static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; - /** * Represents the human-readable identifier of the node/instance to which a request was routed. */ @@ -834,15 +961,30 @@ static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.n environment (aka deployment tier). * *

    Notes: -

    • {@code deployment.environment} does not affect the uniqueness constraints defined through -the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource +
      • {@code deployment.environment.name} does not affect the uniqueness constraints defined +through the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource attributes. This implies that resources carrying the following attribute combinations MUST be considered to be identifying the same service:
      • {@code service.name=frontend}, {@code -deployment.environment=production}
      • {@code service.name=frontend}, {@code -deployment.environment=staging}.
      • +deployment.environment.name=production}
      • {@code service.name=frontend}, {@code +deployment.environment.name=staging}.
      */ -static constexpr const char *kDeploymentEnvironment = "deployment.environment"; +static constexpr const char *kDeploymentEnvironmentName = "deployment.environment.name"; + +/** + * The id of the deployment. + */ +static constexpr const char *kDeploymentId = "deployment.id"; + +/** + * The name of the deployment. + */ +static constexpr const char *kDeploymentName = "deployment.name"; + +/** + * The status of the deployment. + */ +static constexpr const char *kDeploymentStatus = "deployment.status"; /** * Deprecated use the {@code device.app.lifecycle} event definition including {@code android.state} @@ -855,6 +997,14 @@ static constexpr const char *kDeploymentEnvironment = "deployment.environment"; */ static constexpr const char *kAndroidState = "android.state"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kContainerCpuState = "container.cpu.state"; + /** * Deprecated, use {@code db.collection.name} instead. * @@ -879,6 +1029,14 @@ static constexpr const char *kDbConnectionString = "db.connection_string"; OPENTELEMETRY_DEPRECATED static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; +/** + * Deprecated, use {@code db.namespace} instead. + * + * @deprecated Deprecated, use `db.namespace` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; + /** * Deprecated, no general replacement at this time. For Elasticsearch, use {@code * db.elasticsearch.node.name} instead. @@ -963,21 +1121,85 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbUser = "db.user"; /** - * Deprecated, use {@code db.client.connections.pool.name} instead. + * Deprecated, use {@code db.client.connection.pool.name} instead. + * + * @deprecated Deprecated, use `db.client.connection.pool.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; + +/** + * Deprecated, use {@code db.client.connection.state} instead. + * + * @deprecated Deprecated, use `db.client.connection.state` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; + +/** + * Deprecated, use {@code db.client.connection.pool.name} instead. * - * @deprecated Deprecated, use `db.client.connections.pool.name` instead. + * @deprecated Deprecated, use `db.client.connection.pool.name` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kPoolName = "pool.name"; /** - * Deprecated, use {@code db.client.connections.state} instead. + * Deprecated, use {@code db.client.connection.state} instead. * - * @deprecated Deprecated, use `db.client.connections.state` instead. + * @deprecated Deprecated, use `db.client.connection.state` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kState = "state"; +/** + * 'Deprecated, use {@code deployment.environment.name} instead.' + * + * @deprecated 'Deprecated, use `deployment.environment.name` instead.'. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDeploymentEnvironment = "deployment.environment"; + +/** + * Deprecated, use {@code user.id} instead. + * + * @deprecated Deprecated, use `user.id` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserId = "enduser.id"; + +/** + * Deprecated, use {@code user.roles} instead. + * + * @deprecated Deprecated, use `user.roles` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserRole = "enduser.role"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserScope = "enduser.scope"; + +/** + * Deprecated, use {@code gen_ai.usage.output_tokens} instead. + * + * @deprecated Deprecated, use `gen_ai.usage.output_tokens` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; + +/** + * Deprecated, use {@code gen_ai.usage.input_tokens} instead. + * + * @deprecated Deprecated, use `gen_ai.usage.input_tokens` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; + /** * Deprecated, use {@code client.address} instead. * @@ -1109,6 +1331,41 @@ static constexpr const char *kHttpUserAgent = "http.user_agent"; OPENTELEMETRY_DEPRECATED static constexpr const char *kIosState = "ios.state"; +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; + +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingEventhubsConsumerGroup = + "messaging.eventhubs.consumer.group"; + +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; + /** * Deprecated, use {@code messaging.destination.partition.id} instead. * @@ -1118,6 +1375,14 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingKafkaDestinationPartition = "messaging.kafka.destination.partition"; +/** + * Deprecated, use {@code messaging.kafka.offset} instead. + * + * @deprecated Deprecated, use `messaging.kafka.offset` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; + /** * Deprecated, use {@code messaging.operation.type} instead. * @@ -1126,6 +1391,23 @@ static constexpr const char *kMessagingKafkaDestinationPartition = OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingOperation = "messaging.operation"; +/** + * Deprecated, use {@code messaging.consumer.group.name} instead. + * + * @deprecated Deprecated, use `messaging.consumer.group.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; + +/** + * Deprecated, use {@code messaging.servicebus.destination.subscription_name} instead. + * + * @deprecated Deprecated, use `messaging.servicebus.destination.subscription_name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingServicebusDestinationSubscriptionName = + "messaging.servicebus.destination.subscription_name"; + /** * Deprecated, use {@code network.local.address}. * @@ -1249,21 +1531,29 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kNetTransport = "net.transport"; /** - * None * - * @deprecated None. + * + * @deprecated . */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryName = "otel.library.name"; /** - * None * - * @deprecated None. + * + * @deprecated . */ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryVersion = "otel.library.version"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kProcessCpuState = "process.cpu.state"; + /** * Deprecated, use {@code rpc.message.compressed_size} instead. * @@ -1296,6 +1586,14 @@ static constexpr const char *kMessageType = "message.type"; OPENTELEMETRY_DEPRECATED static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; +/** + * Deprecated, use {@code cpu.mode} instead. + * + * @deprecated Deprecated, use `cpu.mode` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kSystemCpuState = "system.cpu.state"; + /** * Deprecated, use {@code system.process.status} instead. * @@ -1304,6 +1602,14 @@ static constexpr const char *kMessageUncompressedSize = "message.uncompressed_si OPENTELEMETRY_DEPRECATED static constexpr const char *kSystemProcessesStatus = "system.processes.status"; +/** + * Deprecated, use {@code server.address} instead. + * + * @deprecated Deprecated, use `server.address` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kTlsClientServerName = "tls.client.server_name"; + /** * Destination address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. @@ -1382,29 +1688,6 @@ static constexpr const char *kDiskIoDirection = "disk.io.direction"; */ static constexpr const char *kDnsQuestionName = "dns.question.name"; -/** - * Username or client_id extracted from the access token or Authorization header in the inbound - * request from outside the system. - */ -static constexpr const char *kEnduserId = "enduser.id"; - -/** - * Actual/assumed role the client is making the request under extracted from token or application - * security context. - */ -static constexpr const char *kEnduserRole = "enduser.role"; - -/** - * 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 *kEnduserScope = "enduser.scope"; - /** * Describes a class of error the operation ended with. * @@ -1430,9 +1713,9 @@ static constexpr const char *kErrorType = "error.type"; * *

      Notes:

      • Event names are subject to the same rules as attribute - names. Notably, event names are namespaced to avoid collisions and provide a clean separation - of semantics for events in separate domains like browser, mobile, and kubernetes.
      + href="/docs/general/attribute-naming.md">attribute names. Notably, event names are namespaced + to avoid collisions and provide a clean separation of semantics for events in separate domains like + browser, mobile, and kubernetes.
    */ static constexpr const char *kEventName = "event.name"; @@ -1667,6 +1950,16 @@ static constexpr const char *kFilePath = "file.path"; */ static constexpr const char *kFileSize = "file.size"; +/** + * Identifies the Google Cloud service for which the official client library is intended. + * + *

    Notes: +

    • Intended to be a stable identifier for Google Cloud client libraries that is uniform + across implementation languages. The value should be derived from the canonical service domain for + the service; for example, 'foo.googleapis.com' should result in a value of 'foo'.
    + */ +static constexpr const char *kGcpClientService = "gcp.client.service"; + /** * The name of the Cloud Run execution being run for the @@ -1699,7 +1992,7 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; /** - * The full response received from the LLM. + * The full response received from the GenAI model. * *

    Notes:

    • It's RECOMMENDED to format completions as JSON string matching Notes: +
      • If one of the predefined values applies, but specific system uses a different name it's + RECOMMENDED to document it in the semantic conventions for specific GenAI system and use + system-specific name in the instrumentation. If a different name is not documented, instrumentation + libraries SHOULD use applicable predefined value.
      + */ +static constexpr const char *kGenAiOperationName = "gen_ai.operation.name"; + +/** + * The full prompt sent to the GenAI model. * *

      Notes:

      • It's RECOMMENDED to format prompts as JSON string matching Notes: -
        • The actual GenAI product may differ from the one identified by the client. For example, - when using OpenAI client libraries to communicate with Mistral, the {@code gen_ai.system} is set to - {@code openai} based on the instrumentation's best knowledge.
        +
        • The {@code gen_ai.system} describes a family of GenAI models with specific model +identified by {@code gen_ai.request.model} and {@code gen_ai.response.model} attributes.
        • The +actual GenAI product may differ from the one identified by the client. For example, when using +OpenAI client libraries to communicate with Mistral, the {@code gen_ai.system} is set to {@code +openai} based on the instrumentation's best knowledge.
        • For custom model, a custom friendly +name SHOULD be used. If none of these options apply, the {@code gen_ai.system} SHOULD be set to +{@code _OTHER}.
        */ static constexpr const char *kGenAiSystem = "gen_ai.system"; /** - * The number of tokens used in the LLM response (completion). + * The type of token being counted. */ -static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; +static constexpr const char *kGenAiTokenType = "gen_ai.token.type"; /** - * The number of tokens used in the LLM prompt. + * The number of tokens used in the GenAI input (prompt). */ -static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; +static constexpr const char *kGenAiUsageInputTokens = "gen_ai.usage.input_tokens"; + +/** + * The number of tokens used in the GenAI response (completion). + */ +static constexpr const char *kGenAiUsageOutputTokens = "gen_ai.usage.output_tokens"; + +/** + * The type of memory. + */ +static constexpr const char *kGoMemoryType = "go.memory.type"; /** * The GraphQL document being executed. @@ -2178,6 +2516,11 @@ static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; */ static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; +/** + * The Linux Slab memory state + */ +static constexpr const char *kLinuxMemorySlabState = "linux.memory.slab.state"; + /** * The stream associated with the log. See below for a list of well-known values. */ @@ -2203,6 +2546,16 @@ static constexpr const char *kLogFilePath = "log.file.path"; */ static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; +/** + * The complete orignal Log Record. + * + *

        Notes: +

        • This value MAY be added when processing a Log Record which was originally transmitted as + a string or equivalent data type AND the Body field of the Log Record does not contain the same + value. (e.g. a syslog or a log record read from a file.)
        + */ +static constexpr const char *kLogRecordOriginal = "log.record.original"; + /** * A unique identifier for the Log Record. * @@ -2231,6 +2584,16 @@ static constexpr const char *kMessagingBatchMessageCount = "messaging.batch.mess */ static constexpr const char *kMessagingClientId = "messaging.client.id"; +/** + * The name of the consumer group with which a consumer is associated. + * + *

        Notes: +

        • Semantic conventions for individual messaging systems SHOULD document whether {@code + messaging.consumer.group.name} is applicable and what it means in the context of that system.
        • +
        + */ +static constexpr const char *kMessagingConsumerGroupName = "messaging.consumer.group.name"; + /** * A boolean that is true if the message destination is anonymous (could be unnamed or have * auto-generated name). @@ -2254,6 +2617,17 @@ static constexpr const char *kMessagingDestinationName = "messaging.destination. static constexpr const char *kMessagingDestinationPartitionId = "messaging.destination.partition.id"; +/** + * The name of the destination subscription from which a message is consumed. + * + *

        Notes: +

        • Semantic conventions for individual messaging systems SHOULD document whether {@code + messaging.destination.subscription.name} is applicable and what it means in the context of that + system.
        + */ +static constexpr const char *kMessagingDestinationSubscriptionName = + "messaging.destination.subscription.name"; + /** * Low cardinality representation of the messaging destination name * @@ -2271,24 +2645,6 @@ static constexpr const char *kMessagingDestinationTemplate = "messaging.destinat */ static constexpr const char *kMessagingDestinationTemporary = "messaging.destination.temporary"; -/** - * A boolean that is true if the publish message destination is anonymous (could be unnamed or have - * auto-generated name). - */ -static constexpr const char *kMessagingDestinationPublishAnonymous = - "messaging.destination_publish.anonymous"; - -/** - * The name of the original destination the message was published to - * - *

        Notes: -

        • The name SHOULD uniquely identify a specific queue, topic, or other entity within the -broker. If the broker doesn't have such notion, the original destination name SHOULD uniquely -identify the broker.
        - */ -static constexpr const char *kMessagingDestinationPublishName = - "messaging.destination_publish.name"; - /** * The size of the message body in bytes. * @@ -2341,12 +2697,6 @@ static constexpr const char *kMessagingOperationType = "messaging.operation.type */ static constexpr const char *kMessagingSystem = "messaging.system"; -/** - * Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not - * producers. - */ -static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; - /** * 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 @@ -2360,14 +2710,14 @@ static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.con static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; /** - * The offset of a record in the corresponding Kafka partition. + * A boolean that is true if the message is a tombstone. */ -static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; +static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; /** - * A boolean that is true if the message is a tombstone. + * The offset of a record in the corresponding Kafka partition. */ -static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; +static constexpr const char *kMessagingKafkaOffset = "messaging.kafka.offset"; /** * RabbitMQ message routing key. @@ -2381,12 +2731,6 @@ static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = static constexpr const char *kMessagingRabbitmqMessageDeliveryTag = "messaging.rabbitmq.message.delivery_tag"; -/** - * Name of the RocketMQ producer/consumer group that is handling the message. The client type is - * identified by the SpanKind. - */ -static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; - /** * Model of message consumption. This only applies to consumer spans. */ @@ -2456,12 +2800,6 @@ static constexpr const char *kMessagingGcpPubsubMessageDeliveryAttempt = static constexpr const char *kMessagingGcpPubsubMessageOrderingKey = "messaging.gcp_pubsub.message.ordering_key"; -/** - * The name of the subscription in the topic messages are received from. - */ -static constexpr const char *kMessagingServicebusDestinationSubscriptionName = - "messaging.servicebus.destination.subscription_name"; - /** * Describes the
        settlement @@ -2482,12 +2820,6 @@ static constexpr const char *kMessagingServicebusMessageDeliveryCount = static constexpr const char *kMessagingServicebusMessageEnqueuedTime = "messaging.servicebus.message.enqueued_time"; -/** - * The name of the consumer group the event consumer is associated with. - */ -static constexpr const char *kMessagingEventhubsConsumerGroup = - "messaging.eventhubs.consumer.group"; - /** * The UTC epoch seconds at which the message has been accepted and stored in the entity. */ @@ -2771,8 +3103,7 @@ static constexpr const char *kProcessRealUserName = "process.real_user.name"; 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 - * the compiler. + * The name of the runtime of this process. */ static constexpr const char *kProcessRuntimeName = "process.runtime.name"; @@ -2816,11 +3147,6 @@ static constexpr const char *kProcessUserName = "process.user.name"; */ static constexpr const char *kProcessVpid = "process.vpid"; -/** - * The CPU state of the process. - */ -static constexpr const char *kProcessCpuState = "process.cpu.state"; - /** * The error codes of the Connect * request. Error codes are always string values. @@ -3040,11 +3366,6 @@ static constexpr const char *kSystemDevice = "system.device"; */ static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; -/** - * The state of the CPU - */ -static constexpr const char *kSystemCpuState = "system.cpu.state"; - /** * The memory state */ @@ -3136,6 +3457,27 @@ static constexpr const char *kTelemetryDistroName = "telemetry.distro.name"; */ static constexpr const char *kTelemetryDistroVersion = "telemetry.distro.version"; +/** + * The fully qualified human readable name of the test case. + */ +static constexpr const char *kTestCaseName = "test.case.name"; + +/** + * The status of the actual test case result from test execution. + */ +static constexpr const char *kTestCaseResultStatus = "test.case.result.status"; + +/** + * The human readable name of a test suite. + */ +static constexpr const char *kTestSuiteName = "test.suite.name"; + +/** + * The status of the test suite run. + */ +static constexpr const char *kTestSuiteRunStatus = "test.suite.run.status"; + /** * Current "managed" thread ID (as opposed to OS thread ID). */ @@ -3215,12 +3557,6 @@ static constexpr const char *kTlsClientNotAfter = "tls.client.not_after"; */ static constexpr const char *kTlsClientNotBefore = "tls.client.not_before"; -/** - * Also called an SNI, this tells the server which hostname to which the client is attempting to - * connect to. - */ -static constexpr const char *kTlsClientServerName = "tls.client.server_name"; - /** * Distinguished name of subject of the x.509 certificate presented by the client. */ @@ -3483,6 +3819,102 @@ static constexpr const char *kUserAgentOriginal = "user_agent.original"; */ static constexpr const char *kUserAgentVersion = "user_agent.version"; +/** + * User email address. + */ +static constexpr const char *kUserEmail = "user.email"; + +/** + * User's full name + */ +static constexpr const char *kUserFullName = "user.full_name"; + +/** + * Unique user hash to correlate information for a user in anonymized form. + * + *

        Notes: +

        • Useful if {@code user.id} or {@code user.name} contain confidential information and + cannot be used.
        + */ +static constexpr const char *kUserHash = "user.hash"; + +/** + * Unique identifier of the user. + */ +static constexpr const char *kUserId = "user.id"; + +/** + * Short name or login/username of the user. + */ +static constexpr const char *kUserName = "user.name"; + +/** + * Array of user roles at the time of the event. + */ +static constexpr const char *kUserRoles = "user.roles"; + +/** + * The type of garbage collection. + */ +static constexpr const char *kV8jsGcType = "v8js.gc.type"; + +/** + * The name of the space type of heap memory. + * + *

        Notes: +

        + */ +static constexpr const char *kV8jsHeapSpaceName = "v8js.heap.space.name"; + +/** + * The ID of the change (pull request/merge request) if applicable. This is usually a unique (within + * repository) identifier generated by the VCS system. + */ +static constexpr const char *kVcsRepositoryChangeId = "vcs.repository.change.id"; + +/** + * The human readable title of the change (pull request/merge request). This title is often a brief + * summary of the change and may get merged in to a ref as the commit summary. + */ +static constexpr const char *kVcsRepositoryChangeTitle = "vcs.repository.change.title"; + +/** + * The name of the reference such as + * branch or tag in the repository. + */ +static constexpr const char *kVcsRepositoryRefName = "vcs.repository.ref.name"; + +/** + * The revision, literally revised +version, The revision most often refers to a commit object in Git, or a revision number in SVN. + * + *

        Notes: +

        • The revision can be a full hash value (see glossary), of +the recorded change to a ref within a repository pointing to a commit commit object. It does not necessarily have to be a +hash; it can simply define a revision number which +is an integer that is monotonically increasing. In cases where it is identical to the {@code +ref.name}, it SHOULD still be included. It is up to the implementer to decide which value to set as +the revision based on the VCS system and situational context.
        + */ +static constexpr const char *kVcsRepositoryRefRevision = "vcs.repository.ref.revision"; + +/** + * The type of the reference in the + * repository. + */ +static constexpr const char *kVcsRepositoryRefType = "vcs.repository.ref.type"; + +/** + * The URL of the repository providing the complete + * address in order to locate and identify the repository. + */ +static constexpr const char *kVcsRepositoryUrlFull = "vcs.repository.url.full"; + /** * Additional description of the web engine (e.g. detailed version and edition information). */ @@ -3539,6 +3971,16 @@ static constexpr const char *kEc2 = "ec2"; static constexpr const char *kFargate = "fargate"; } // namespace AwsEcsLaunchtypeValues +namespace CicdPipelineTaskTypeValues +{ +/** build. */ +static constexpr const char *kBuild = "build"; +/** test. */ +static constexpr const char *kTest = "test"; +/** deploy. */ +static constexpr const char *kDeploy = "deploy"; +} // namespace CicdPipelineTaskTypeValues + namespace CloudPlatformValues { /** Alibaba Cloud Elastic Compute Service. */ @@ -3617,132 +4059,144 @@ static constexpr const char *kIbmCloud = "ibm_cloud"; static constexpr const char *kTencentCloud = "tencent_cloud"; } // namespace CloudProviderValues -namespace ContainerCpuStateValues +namespace CpuModeValues { -/** When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode - * (Windows). */ +/** user. */ static constexpr const char *kUser = "user"; -/** When CPU is used by the system (host OS). */ +/** system. */ static constexpr const char *kSystem = "system"; -/** When tasks of the cgroup are in kernel mode (Linux). When all container processes are in kernel - * mode (Windows). */ +/** 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"; +/** kernel. */ static constexpr const char *kKernel = "kernel"; -} // namespace ContainerCpuStateValues +} // namespace CpuModeValues -namespace DbClientConnectionsStateValues +namespace DbClientConnectionStateValues { /** idle. */ static constexpr const char *kIdle = "idle"; /** used. */ static constexpr const char *kUsed = "used"; -} // namespace DbClientConnectionsStateValues +} // namespace DbClientConnectionStateValues namespace DbSystemValues { /** Some other SQL database. Fallback only. See notes. */ static constexpr const char *kOtherSql = "other_sql"; -/** Microsoft SQL Server. */ -static constexpr const char *kMssql = "mssql"; -/** Microsoft SQL Server Compact. */ -static constexpr const char *kMssqlcompact = "mssqlcompact"; -/** MySQL. */ -static constexpr const char *kMysql = "mysql"; -/** Oracle Database. */ -static constexpr const char *kOracle = "oracle"; -/** IBM Db2. */ -static constexpr const char *kDb2 = "db2"; -/** PostgreSQL. */ -static constexpr const char *kPostgresql = "postgresql"; -/** Amazon Redshift. */ -static constexpr const char *kRedshift = "redshift"; -/** Apache Hive. */ -static constexpr const char *kHive = "hive"; -/** Cloudscape. */ -static constexpr const char *kCloudscape = "cloudscape"; -/** HyperSQL DataBase. */ -static constexpr const char *kHsqldb = "hsqldb"; -/** Progress Database. */ -static constexpr const char *kProgress = "progress"; -/** SAP MaxDB. */ -static constexpr const char *kMaxdb = "maxdb"; -/** SAP HANA. */ -static constexpr const char *kHanadb = "hanadb"; -/** Ingres. */ -static constexpr const char *kIngres = "ingres"; -/** FirstSQL. */ -static constexpr const char *kFirstsql = "firstsql"; -/** EnterpriseDB. */ -static constexpr const char *kEdb = "edb"; -/** InterSystems Caché. */ -static constexpr const char *kCache = "cache"; /** Adabas (Adaptable Database System). */ static constexpr const char *kAdabas = "adabas"; -/** Firebird. */ -static constexpr const char *kFirebird = "firebird"; +/** Deprecated, use `intersystems_cache` instead. */ +static constexpr const char *kCache = "cache"; +/** InterSystems Caché. */ +static constexpr const char *kIntersystemsCache = "intersystems_cache"; +/** Apache Cassandra. */ +static constexpr const char *kCassandra = "cassandra"; +/** ClickHouse. */ +static constexpr const char *kClickhouse = "clickhouse"; +/** Deprecated, use `other_sql` instead. */ +static constexpr const char *kCloudscape = "cloudscape"; +/** CockroachDB. */ +static constexpr const char *kCockroachdb = "cockroachdb"; +/** Deprecated, no replacement at this time. */ +static constexpr const char *kColdfusion = "coldfusion"; +/** Microsoft Azure Cosmos DB. */ +static constexpr const char *kCosmosdb = "cosmosdb"; +/** Couchbase. */ +static constexpr const char *kCouchbase = "couchbase"; +/** CouchDB. */ +static constexpr const char *kCouchdb = "couchdb"; +/** IBM Db2. */ +static constexpr const char *kDb2 = "db2"; /** Apache Derby. */ static constexpr const char *kDerby = "derby"; +/** Amazon DynamoDB. */ +static constexpr const char *kDynamodb = "dynamodb"; +/** EnterpriseDB. */ +static constexpr const char *kEdb = "edb"; +/** Elasticsearch. */ +static constexpr const char *kElasticsearch = "elasticsearch"; /** FileMaker. */ static constexpr const char *kFilemaker = "filemaker"; +/** Firebird. */ +static constexpr const char *kFirebird = "firebird"; +/** Deprecated, use `other_sql` instead. */ +static constexpr const char *kFirstsql = "firstsql"; +/** Apache Geode. */ +static constexpr const char *kGeode = "geode"; +/** H2. */ +static constexpr const char *kH2 = "h2"; +/** SAP HANA. */ +static constexpr const char *kHanadb = "hanadb"; +/** Apache HBase. */ +static constexpr const char *kHbase = "hbase"; +/** Apache Hive. */ +static constexpr const char *kHive = "hive"; +/** HyperSQL DataBase. */ +static constexpr const char *kHsqldb = "hsqldb"; +/** InfluxDB. */ +static constexpr const char *kInfluxdb = "influxdb"; /** Informix. */ static constexpr const char *kInformix = "informix"; +/** Ingres. */ +static constexpr const char *kIngres = "ingres"; /** InstantDB. */ static constexpr const char *kInstantdb = "instantdb"; /** InterBase. */ static constexpr const char *kInterbase = "interbase"; /** MariaDB. */ static constexpr const char *kMariadb = "mariadb"; +/** SAP MaxDB. */ +static constexpr const char *kMaxdb = "maxdb"; +/** Memcached. */ +static constexpr const char *kMemcached = "memcached"; +/** MongoDB. */ +static constexpr const char *kMongodb = "mongodb"; +/** Microsoft SQL Server. */ +static constexpr const char *kMssql = "mssql"; +/** Deprecated, Microsoft SQL Server Compact is discontinued. */ +static constexpr const char *kMssqlcompact = "mssqlcompact"; +/** MySQL. */ +static constexpr const char *kMysql = "mysql"; +/** Neo4j. */ +static constexpr const char *kNeo4j = "neo4j"; /** Netezza. */ static constexpr const char *kNetezza = "netezza"; +/** OpenSearch. */ +static constexpr const char *kOpensearch = "opensearch"; +/** Oracle Database. */ +static constexpr const char *kOracle = "oracle"; /** Pervasive PSQL. */ static constexpr const char *kPervasive = "pervasive"; /** PointBase. */ static constexpr const char *kPointbase = "pointbase"; +/** PostgreSQL. */ +static constexpr const char *kPostgresql = "postgresql"; +/** Progress Database. */ +static constexpr const char *kProgress = "progress"; +/** Redis. */ +static constexpr const char *kRedis = "redis"; +/** Amazon Redshift. */ +static constexpr const char *kRedshift = "redshift"; +/** Cloud Spanner. */ +static constexpr const char *kSpanner = "spanner"; /** SQLite. */ static constexpr const char *kSqlite = "sqlite"; /** Sybase. */ static constexpr const char *kSybase = "sybase"; /** Teradata. */ static constexpr const char *kTeradata = "teradata"; -/** Vertica. */ -static constexpr const char *kVertica = "vertica"; -/** H2. */ -static constexpr const char *kH2 = "h2"; -/** ColdFusion IMQ. */ -static constexpr const char *kColdfusion = "coldfusion"; -/** Apache Cassandra. */ -static constexpr const char *kCassandra = "cassandra"; -/** Apache HBase. */ -static constexpr const char *kHbase = "hbase"; -/** MongoDB. */ -static constexpr const char *kMongodb = "mongodb"; -/** Redis. */ -static constexpr const char *kRedis = "redis"; -/** Couchbase. */ -static constexpr const char *kCouchbase = "couchbase"; -/** CouchDB. */ -static constexpr const char *kCouchdb = "couchdb"; -/** Microsoft Azure Cosmos DB. */ -static constexpr const char *kCosmosdb = "cosmosdb"; -/** Amazon DynamoDB. */ -static constexpr const char *kDynamodb = "dynamodb"; -/** Neo4j. */ -static constexpr const char *kNeo4j = "neo4j"; -/** Apache Geode. */ -static constexpr const char *kGeode = "geode"; -/** Elasticsearch. */ -static constexpr const char *kElasticsearch = "elasticsearch"; -/** Memcached. */ -static constexpr const char *kMemcached = "memcached"; -/** CockroachDB. */ -static constexpr const char *kCockroachdb = "cockroachdb"; -/** OpenSearch. */ -static constexpr const char *kOpensearch = "opensearch"; -/** ClickHouse. */ -static constexpr const char *kClickhouse = "clickhouse"; -/** Cloud Spanner. */ -static constexpr const char *kSpanner = "spanner"; /** Trino. */ static constexpr const char *kTrino = "trino"; +/** Vertica. */ +static constexpr const char *kVertica = "vertica"; } // namespace DbSystemValues namespace DbCassandraConsistencyLevelValues @@ -3813,6 +4267,14 @@ static constexpr const char *kQueryPlan = "QueryPlan"; static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; } // namespace DbCosmosdbOperationTypeValues +namespace DeploymentStatusValues +{ +/** failed. */ +static constexpr const char *kFailed = "failed"; +/** succeeded. */ +static constexpr const char *kSucceeded = "succeeded"; +} // namespace DeploymentStatusValues + namespace AndroidStateValues { /** Any time before Activity.onResume() or, if the app has no Activity, Context.startService() has @@ -3826,6 +4288,26 @@ static constexpr const char *kBackground = "background"; static constexpr const char *kForeground = "foreground"; } // namespace AndroidStateValues +namespace ContainerCpuStateValues +{ +/** When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode + * (Windows). */ +static constexpr const char *kUser = "user"; +/** When CPU is used by the system (host OS). */ +static constexpr const char *kSystem = "system"; +/** When tasks of the cgroup are in kernel mode (Linux). When all container processes are in kernel + * mode (Windows). */ +static constexpr const char *kKernel = "kernel"; +} // namespace ContainerCpuStateValues + +namespace DbClientConnectionsStateValues +{ +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** used. */ +static constexpr const char *kUsed = "used"; +} // namespace DbClientConnectionsStateValues + namespace StateValues { /** idle. */ @@ -3890,6 +4372,16 @@ static constexpr const char *kInproc = "inproc"; static constexpr const char *kOther = "other"; } // namespace NetTransportValues +namespace ProcessCpuStateValues +{ +/** system. */ +static constexpr const char *kSystem = "system"; +/** user. */ +static constexpr const char *kUser = "user"; +/** wait. */ +static constexpr const char *kWait = "wait"; +} // namespace ProcessCpuStateValues + namespace MessageTypeValues { /** sent. */ @@ -3898,6 +4390,24 @@ static constexpr const char *kSent = "SENT"; static constexpr const char *kReceived = "RECEIVED"; } // namespace MessageTypeValues +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 SystemProcessesStatusValues { /** running. */ @@ -3962,12 +4472,46 @@ static constexpr const char *kTimer = "timer"; static constexpr const char *kOther = "other"; } // namespace FaasTriggerValues +namespace GenAiOperationNameValues +{ +/** Chat completion operation such as [OpenAI Chat + * API](https://platform.openai.com/docs/api-reference/chat). */ +static constexpr const char *kChat = "chat"; +/** Text completions operation such as [OpenAI Completions API + * (Legacy)](https://platform.openai.com/docs/api-reference/completions). */ +static constexpr const char *kTextCompletion = "text_completion"; +} // namespace GenAiOperationNameValues + namespace GenAiSystemValues { /** OpenAI. */ static constexpr const char *kOpenai = "openai"; +/** Vertex AI. */ +static constexpr const char *kVertexAi = "vertex_ai"; +/** Anthropic. */ +static constexpr const char *kAnthropic = "anthropic"; +/** Cohere. */ +static constexpr const char *kCohere = "cohere"; } // namespace GenAiSystemValues +namespace GenAiTokenTypeValues +{ +/** Input tokens (prompt, input, etc.). */ +static constexpr const char *kInput = "input"; +/** Output tokens (completion, response, etc.). */ +static constexpr const char *kCompletion = "output"; +} // namespace GenAiTokenTypeValues + +namespace GoMemoryTypeValues +{ +/** Memory allocated from the heap that is reserved for stack space, whether or not it is currently + * in-use. */ +static constexpr const char *kStack = "stack"; +/** Memory used by the Go runtime, excluding other categories of memory usage described in this + * enumeration. */ +static constexpr const char *kOther = "other"; +} // namespace GoMemoryTypeValues + namespace GraphqlOperationTypeValues { /** GraphQL query. */ @@ -4056,6 +4600,14 @@ static constexpr const char *kTimedWaiting = "timed_waiting"; static constexpr const char *kTerminated = "terminated"; } // namespace JvmThreadStateValues +namespace LinuxMemorySlabStateValues +{ +/** reclaimable. */ +static constexpr const char *kReclaimable = "reclaimable"; +/** unreclaimable. */ +static constexpr const char *kUnreclaimable = "unreclaimable"; +} // namespace LinuxMemorySlabStateValues + namespace LogIostreamValues { /** Logs from stdout stream. */ @@ -4076,10 +4628,12 @@ static constexpr const char *kCreate = "create"; /** One or more messages are requested by a consumer. This operation refers to pull-based scenarios, * where consumers explicitly call methods of messaging SDKs to receive messages. */ static constexpr const char *kReceive = "receive"; -/** One or more messages are delivered to or processed by a consumer. */ -static constexpr const char *kDeliver = "process"; +/** One or more messages are processed by a consumer. */ +static constexpr const char *kProcess = "process"; /** One or more messages are settled. */ static constexpr const char *kSettle = "settle"; +/** Deprecated. Use `process` instead. */ +static constexpr const char *kDeliver = "deliver"; } // namespace MessagingOperationTypeValues namespace MessagingSystemValues @@ -4104,6 +4658,8 @@ static constexpr const char *kKafka = "kafka"; static constexpr const char *kRabbitmq = "rabbitmq"; /** Apache RocketMQ. */ static constexpr const char *kRocketmq = "rocketmq"; +/** Apache Pulsar. */ +static constexpr const char *kPulsar = "pulsar"; } // namespace MessagingSystemValues namespace MessagingRocketmqConsumptionModelValues @@ -4216,6 +4772,8 @@ static constexpr const char *kUdp = "udp"; static constexpr const char *kPipe = "pipe"; /** Unix domain socket. */ static constexpr const char *kUnix = "unix"; +/** QUIC. */ +static constexpr const char *kQuic = "quic"; } // namespace NetworkTransportValues namespace NetworkTypeValues @@ -4285,16 +4843,6 @@ static constexpr const char *kMajor = "major"; static constexpr const char *kMinor = "minor"; } // namespace ProcessPagingFaultTypeValues -namespace ProcessCpuStateValues -{ -/** system. */ -static constexpr const char *kSystem = "system"; -/** user. */ -static constexpr const char *kUser = "user"; -/** wait. */ -static constexpr const char *kWait = "wait"; -} // namespace ProcessCpuStateValues - namespace RpcConnectRpcErrorCodeValues { /** cancelled. */ @@ -4411,24 +4959,6 @@ static constexpr const char *kLongPolling = "long_polling"; static constexpr const char *kWebSockets = "web_sockets"; } // namespace SignalrTransportValues -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 { /** used. */ @@ -4561,6 +5091,30 @@ static constexpr const char *kSwift = "swift"; static constexpr const char *kWebjs = "webjs"; } // namespace TelemetrySdkLanguageValues +namespace TestCaseResultStatusValues +{ +/** pass. */ +static constexpr const char *kPass = "pass"; +/** fail. */ +static constexpr const char *kFail = "fail"; +} // namespace TestCaseResultStatusValues + +namespace TestSuiteRunStatusValues +{ +/** success. */ +static constexpr const char *kSuccess = "success"; +/** failure. */ +static constexpr const char *kFailure = "failure"; +/** skipped. */ +static constexpr const char *kSkipped = "skipped"; +/** aborted. */ +static constexpr const char *kAborted = "aborted"; +/** timed_out. */ +static constexpr const char *kTimedOut = "timed_out"; +/** in_progress. */ +static constexpr const char *kInProgress = "in_progress"; +} // namespace TestSuiteRunStatusValues + namespace TlsProtocolNameValues { /** ssl. */ @@ -4569,6 +5123,40 @@ static constexpr const char *kSsl = "ssl"; static constexpr const char *kTls = "tls"; } // namespace TlsProtocolNameValues +namespace V8jsGcTypeValues +{ +/** Major (Mark Sweep Compact). */ +static constexpr const char *kMajor = "major"; +/** Minor (Scavenge). */ +static constexpr const char *kMinor = "minor"; +/** Incremental (Incremental Marking). */ +static constexpr const char *kIncremental = "incremental"; +/** Weak Callbacks (Process Weak Callbacks). */ +static constexpr const char *kWeakcb = "weakcb"; +} // namespace V8jsGcTypeValues + +namespace V8jsHeapSpaceNameValues +{ +/** New memory space. */ +static constexpr const char *kNewSpace = "new_space"; +/** Old memory space. */ +static constexpr const char *kOldSpace = "old_space"; +/** Code memory space. */ +static constexpr const char *kCodeSpace = "code_space"; +/** Map memory space. */ +static constexpr const char *kMapSpace = "map_space"; +/** Large object memory space. */ +static constexpr const char *kLargeObjectSpace = "large_object_space"; +} // namespace V8jsHeapSpaceNameValues + +namespace VcsRepositoryRefTypeValues +{ +/** [branch](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefbranchabranch). */ +static constexpr const char *kBranch = "branch"; +/** [tag](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddeftagatag). */ +static constexpr const char *kTag = "tag"; +} // namespace VcsRepositoryRefTypeValues + } // namespace SemanticConventions } // namespace resource } // namespace sdk diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent.h index d5054d92189..e44e9fa320b 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent.h @@ -27,7 +27,7 @@ namespace trace class ParentBasedSampler : public Sampler { public: - explicit ParentBasedSampler(std::shared_ptr delegate_sampler) noexcept; + explicit ParentBasedSampler(const std::shared_ptr &delegate_sampler) noexcept; /** The decision either respects the parent span's sampling decision or delegates to * delegateSampler for root spans * @return Returns DROP always diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h index 68557ace792..d5cf598311d 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h @@ -23,7 +23,7 @@ class ParentBasedSamplerFactory /** * Create a ParentBasedSampler. */ - static std::unique_ptr Create(std::shared_ptr delegate_sampler); + static std::unique_ptr Create(const std::shared_ptr &delegate_sampler); }; } // namespace trace diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h index dee8e80bb8e..ce6d378b794 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h @@ -7,12 +7,15 @@ #include #include #include +#include #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/span_data.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/span_data.h index 8e301c1a013..2bd8b2112bb 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -11,14 +11,18 @@ #include #include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/macros.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/recordable.h" -#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer.h index fb8342c1d51..f738203b4f2 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer.h @@ -4,12 +4,10 @@ #pragma once #include -#include #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/id_generator.h" diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_context.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_context.h index 73bbe4f84b8..e1b2cb25d27 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_context.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_context.h @@ -39,7 +39,7 @@ class TracerContext public: explicit TracerContext( std::vector> &&processor, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index 0d05a94043b..44d58405584 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -4,7 +4,6 @@ #pragma once #include -#include #include #include @@ -43,7 +42,7 @@ class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::T */ explicit TracerProvider( std::unique_ptr processor, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = @@ -51,7 +50,7 @@ class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::T explicit TracerProvider( std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h index 7c4b6903de1..ed451a8c995 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h @@ -28,68 +28,6 @@ namespace trace class OPENTELEMETRY_EXPORT TracerProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - /* Serie of builders with a single processor. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator); - - /* Serie of builders with a vector of processor. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator); - - /* Create with a tracer context. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - /* Serie of builders with a single processor. */ static std::unique_ptr Create( @@ -134,8 +72,6 @@ class OPENTELEMETRY_EXPORT TracerProviderFactory static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace trace diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h index bfc93238b40..b8f4c076f17 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.16.0" +#define OPENTELEMETRY_SDK_VERSION "1.17.0" #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/sdk/src/common/base64.cc b/deps/opentelemetry-cpp/sdk/src/common/base64.cc index 3c572fe344a..a78b88ad68f 100644 --- a/deps/opentelemetry-cpp/sdk/src/common/base64.cc +++ b/deps/opentelemetry-cpp/sdk/src/common/base64.cc @@ -200,15 +200,10 @@ static int Base64UnescapeInternal(unsigned char *dst, ++line_len; if (src[i] == padding_char) { - if (++j > 2) + if (++j > 2 || (valid_slen & 3) == 1 || (valid_slen & 3) == 2) { return -2; } - else if ((valid_slen & 3) == 1 || (valid_slen & 3) == 2) - { - // First and second char of every group can not be padding char - return -2; - } } else { diff --git a/deps/opentelemetry-cpp/sdk/src/common/global_log_handler.cc b/deps/opentelemetry-cpp/sdk/src/common/global_log_handler.cc index 40968f2b7ec..f60527eee84 100644 --- a/deps/opentelemetry-cpp/sdk/src/common/global_log_handler.cc +++ b/deps/opentelemetry-cpp/sdk/src/common/global_log_handler.cc @@ -31,7 +31,7 @@ void DefaultLogHandler::Handle(LogLevel level, { output_s << msg; } - output_s << std::endl; + output_s << '\n'; // TBD - print attributes switch (level) diff --git a/deps/opentelemetry-cpp/sdk/src/common/random.cc b/deps/opentelemetry-cpp/sdk/src/common/random.cc index 77b88cfa2ae..9b696dea656 100644 --- a/deps/opentelemetry-cpp/sdk/src/common/random.cc +++ b/deps/opentelemetry-cpp/sdk/src/common/random.cc @@ -5,6 +5,7 @@ #include "src/common/random.h" #include "src/common/platform/fork.h" +#include #include #include @@ -26,12 +27,17 @@ class TlsRandomNumberGenerator TlsRandomNumberGenerator() noexcept { Seed(); - platform::AtFork(nullptr, nullptr, OnFork); + if (!flag.test_and_set()) + { + platform::AtFork(nullptr, nullptr, OnFork); + } } static FastRandomNumberGenerator &engine() noexcept { return engine_; } private: + static std::atomic_flag flag; + static thread_local FastRandomNumberGenerator engine_; static void OnFork() noexcept { Seed(); } @@ -44,6 +50,7 @@ class TlsRandomNumberGenerator } }; +std::atomic_flag TlsRandomNumberGenerator::flag; thread_local FastRandomNumberGenerator TlsRandomNumberGenerator::engine_{}; } // namespace diff --git a/deps/opentelemetry-cpp/sdk/src/logs/batch_log_record_processor.cc b/deps/opentelemetry-cpp/sdk/src/logs/batch_log_record_processor.cc index c85d56739e3..f5c35ad3394 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/batch_log_record_processor.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/batch_log_record_processor.cc @@ -208,6 +208,8 @@ void BatchLogRecordProcessor::Export() break; } + // Reserve space for the number of records + records_arr.reserve(num_records_to_export); buffer_.Consume(num_records_to_export, [&](CircularBufferRange> range) noexcept { range.ForEach([&](AtomicUniquePtr &ptr) { diff --git a/deps/opentelemetry-cpp/sdk/src/logs/event_logger.cc b/deps/opentelemetry-cpp/sdk/src/logs/event_logger.cc index 6b0afacfafd..df9ba44c313 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/event_logger.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/event_logger.cc @@ -21,7 +21,7 @@ namespace logs EventLogger::EventLogger( opentelemetry::nostd::shared_ptr delegate_logger, opentelemetry::nostd::string_view event_domain) noexcept - : delegate_logger_(delegate_logger), event_domain_(event_domain) + : delegate_logger_(std::move(delegate_logger)), event_domain_(event_domain) {} const opentelemetry::nostd::string_view EventLogger::GetName() noexcept diff --git a/deps/opentelemetry-cpp/sdk/src/logs/event_logger_provider_factory.cc b/deps/opentelemetry-cpp/sdk/src/logs/event_logger_provider_factory.cc index 7f5c8cadf17..daff8a85908 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/event_logger_provider_factory.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/event_logger_provider_factory.cc @@ -11,22 +11,11 @@ namespace sdk namespace logs { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr EventLoggerProviderFactory::Create() -{ - return std::unique_ptr(new EventLoggerProvider()); -} - -#else - std::unique_ptr EventLoggerProviderFactory::Create() { return std::unique_ptr(new EventLoggerProvider()); } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/logs/logger.cc b/deps/opentelemetry-cpp/sdk/src/logs/logger.cc index d3555ba4ec8..2d57ab9faa7 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/logger.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/logger.cc @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include #include @@ -39,7 +38,7 @@ Logger::Logger( std::unique_ptr instrumentation_scope) noexcept : logger_name_(std::string(name)), instrumentation_scope_(std::move(instrumentation_scope)), - context_(context) + context_(std::move(context)) {} const opentelemetry::nostd::string_view Logger::GetName() noexcept diff --git a/deps/opentelemetry-cpp/sdk/src/logs/logger_context.cc b/deps/opentelemetry-cpp/sdk/src/logs/logger_context.cc index 2bfb89161ec..a6eb0636615 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/logger_context.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/logger_context.cc @@ -19,7 +19,7 @@ namespace logs { LoggerContext::LoggerContext(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept : resource_(resource), processor_( std::unique_ptr(new MultiLogRecordProcessor(std::move(processors)))) diff --git a/deps/opentelemetry-cpp/sdk/src/logs/logger_provider.cc b/deps/opentelemetry-cpp/sdk/src/logs/logger_provider.cc index c3b1fb7dd46..46bf1ade335 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/logger_provider.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/logger_provider.cc @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -12,7 +11,6 @@ #include "opentelemetry/logs/logger.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/logger.h" @@ -29,17 +27,17 @@ namespace logs { LoggerProvider::LoggerProvider(std::unique_ptr &&processor, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept { std::vector> processors; processors.emplace_back(std::move(processor)); - context_ = std::make_shared(std::move(processors), std::move(resource)); + context_ = std::make_shared(std::move(processors), resource); OTEL_INTERNAL_LOG_DEBUG("[LoggerProvider] LoggerProvider created."); } LoggerProvider::LoggerProvider(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource) noexcept - : context_{std::make_shared(std::move(processors), std::move(resource))} + const opentelemetry::sdk::resource::Resource &resource) noexcept + : context_{std::make_shared(std::move(processors), resource)} {} LoggerProvider::LoggerProvider() noexcept diff --git a/deps/opentelemetry-cpp/sdk/src/logs/logger_provider_factory.cc b/deps/opentelemetry-cpp/sdk/src/logs/logger_provider_factory.cc index 08567c65d9a..530d1c2db4b 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/logger_provider_factory.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/logger_provider_factory.cc @@ -18,50 +18,6 @@ namespace sdk namespace logs { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr &&processor) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processor), resource); -} - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr &&processor, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(processor), resource)); - return provider; -} - -std::unique_ptr LoggerProviderFactory::Create( - std::vector> &&processors) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processors), resource); -} - -std::unique_ptr LoggerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(processors), resource)); - return provider; -} - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr LoggerProviderFactory::Create( std::unique_ptr &&processor) { @@ -102,8 +58,6 @@ std::unique_ptr LoggerProviderFactory: return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/logs/readable_log_record.cc b/deps/opentelemetry-cpp/sdk/src/logs/readable_log_record.cc index 4c8d1193472..8d35c1eb2eb 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/readable_log_record.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/readable_log_record.cc @@ -7,7 +7,6 @@ #include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/readable_log_record.h" #include "opentelemetry/sdk/resource/resource.h" diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/histogram_aggregation.cc b/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/histogram_aggregation.cc index da725cf09c2..d6b4c90a0b6 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/histogram_aggregation.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/histogram_aggregation.cc @@ -28,7 +28,7 @@ namespace metrics LongHistogramAggregation::LongHistogramAggregation(const AggregationConfig *aggregation_config) { auto ac = static_cast(aggregation_config); - if (ac && ac->boundaries_.size()) + if (ac) { point_data_.boundaries_ = ac->boundaries_; } @@ -109,7 +109,7 @@ PointType LongHistogramAggregation::ToPoint() const noexcept DoubleHistogramAggregation::DoubleHistogramAggregation(const AggregationConfig *aggregation_config) { auto ac = static_cast(aggregation_config); - if (ac && ac->boundaries_.size()) + if (ac) { point_data_.boundaries_ = ac->boundaries_; } diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/lastvalue_aggregation.cc b/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/lastvalue_aggregation.cc index 0380015234b..2bc0eddb0ed 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/lastvalue_aggregation.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/lastvalue_aggregation.cc @@ -28,9 +28,7 @@ LongLastValueAggregation::LongLastValueAggregation() point_data_.value_ = static_cast(0); } -LongLastValueAggregation::LongLastValueAggregation(LastValuePointData &&data) - : point_data_{std::move(data)} -{} +LongLastValueAggregation::LongLastValueAggregation(LastValuePointData &&data) : point_data_{data} {} LongLastValueAggregation::LongLastValueAggregation(const LastValuePointData &data) : point_data_{data} @@ -51,12 +49,12 @@ std::unique_ptr LongLastValueAggregation::Merge( if (nostd::get(ToPoint()).sample_ts_.time_since_epoch() > nostd::get(delta.ToPoint()).sample_ts_.time_since_epoch()) { - LastValuePointData merge_data = std::move(nostd::get(ToPoint())); + LastValuePointData merge_data = nostd::get(ToPoint()); return std::unique_ptr(new LongLastValueAggregation(std::move(merge_data))); } else { - LastValuePointData merge_data = std::move(nostd::get(delta.ToPoint())); + LastValuePointData merge_data = nostd::get(delta.ToPoint()); return std::unique_ptr(new LongLastValueAggregation(std::move(merge_data))); } } @@ -66,12 +64,12 @@ std::unique_ptr LongLastValueAggregation::Diff(const Aggregation &n if (nostd::get(ToPoint()).sample_ts_.time_since_epoch() > nostd::get(next.ToPoint()).sample_ts_.time_since_epoch()) { - LastValuePointData diff_data = std::move(nostd::get(ToPoint())); + LastValuePointData diff_data = nostd::get(ToPoint()); return std::unique_ptr(new LongLastValueAggregation(std::move(diff_data))); } else { - LastValuePointData diff_data = std::move(nostd::get(next.ToPoint())); + LastValuePointData diff_data = nostd::get(next.ToPoint()); return std::unique_ptr(new LongLastValueAggregation(std::move(diff_data))); } } @@ -89,7 +87,7 @@ DoubleLastValueAggregation::DoubleLastValueAggregation() } DoubleLastValueAggregation::DoubleLastValueAggregation(LastValuePointData &&data) - : point_data_{std::move(data)} + : point_data_{data} {} DoubleLastValueAggregation::DoubleLastValueAggregation(const LastValuePointData &data) @@ -111,12 +109,12 @@ std::unique_ptr DoubleLastValueAggregation::Merge( if (nostd::get(ToPoint()).sample_ts_.time_since_epoch() > nostd::get(delta.ToPoint()).sample_ts_.time_since_epoch()) { - LastValuePointData merge_data = std::move(nostd::get(ToPoint())); + LastValuePointData merge_data = nostd::get(ToPoint()); return std::unique_ptr(new DoubleLastValueAggregation(std::move(merge_data))); } else { - LastValuePointData merge_data = std::move(nostd::get(delta.ToPoint())); + LastValuePointData merge_data = nostd::get(delta.ToPoint()); return std::unique_ptr(new DoubleLastValueAggregation(std::move(merge_data))); } } @@ -127,12 +125,12 @@ std::unique_ptr DoubleLastValueAggregation::Diff( if (nostd::get(ToPoint()).sample_ts_.time_since_epoch() > nostd::get(next.ToPoint()).sample_ts_.time_since_epoch()) { - LastValuePointData diff_data = std::move(nostd::get(ToPoint())); + LastValuePointData diff_data = nostd::get(ToPoint()); return std::unique_ptr(new DoubleLastValueAggregation(std::move(diff_data))); } else { - LastValuePointData diff_data = std::move(nostd::get(next.ToPoint())); + LastValuePointData diff_data = nostd::get(next.ToPoint()); return std::unique_ptr(new DoubleLastValueAggregation(std::move(diff_data))); } } diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/sum_aggregation.cc b/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/sum_aggregation.cc index 1e0442e92c2..cd518e54600 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/sum_aggregation.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/aggregation/sum_aggregation.cc @@ -4,7 +4,6 @@ #include #include #include -#include #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/variant.h" @@ -27,7 +26,7 @@ LongSumAggregation::LongSumAggregation(bool is_monotonic) point_data_.is_monotonic_ = is_monotonic; } -LongSumAggregation::LongSumAggregation(SumPointData &&data) : point_data_{std::move(data)} {} +LongSumAggregation::LongSumAggregation(SumPointData &&data) : point_data_{data} {} LongSumAggregation::LongSumAggregation(const SumPointData &data) : point_data_{data} {} @@ -81,7 +80,7 @@ DoubleSumAggregation::DoubleSumAggregation(bool is_monotonic) point_data_.is_monotonic_ = is_monotonic; } -DoubleSumAggregation::DoubleSumAggregation(SumPointData &&data) : point_data_(std::move(data)) {} +DoubleSumAggregation::DoubleSumAggregation(SumPointData &&data) : point_data_(data) {} DoubleSumAggregation::DoubleSumAggregation(const SumPointData &data) : point_data_(data) {} diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/async_instruments.cc b/deps/opentelemetry-cpp/sdk/src/metrics/async_instruments.cc index 311efc1e7e6..709957d68e4 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/async_instruments.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/async_instruments.cc @@ -20,9 +20,9 @@ namespace metrics ObservableInstrument::ObservableInstrument(InstrumentDescriptor instrument_descriptor, std::unique_ptr storage, std::shared_ptr observable_registry) - : instrument_descriptor_(instrument_descriptor), + : instrument_descriptor_(std::move(instrument_descriptor)), storage_(std::move(storage)), - observable_registry_{observable_registry} + observable_registry_{std::move(observable_registry)} {} diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/exemplar/reservoir.cc b/deps/opentelemetry-cpp/sdk/src/metrics/exemplar/reservoir.cc index 4e7501799e6..264a0008284 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/exemplar/reservoir.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/exemplar/reservoir.cc @@ -3,9 +3,11 @@ #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" +# include + # include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" +# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir_cell.h" # include "opentelemetry/sdk/metrics/exemplar/simple_fixed_size_exemplar_reservoir.h" @@ -20,8 +22,8 @@ nostd::shared_ptr ExemplarReservoir::GetSimpleFixedSizeExempl std::shared_ptr reservoir_cell_selector, MapAndResetCellType map_and_reset_cell) { - return nostd::shared_ptr{ - new SimpleFixedSizeExemplarReservoir{size, reservoir_cell_selector, map_and_reset_cell}}; + return nostd::shared_ptr{new SimpleFixedSizeExemplarReservoir{ + size, std::move(reservoir_cell_selector), map_and_reset_cell}}; } nostd::shared_ptr ExemplarReservoir::GetAlignedHistogramBucketExemplarReservoir( @@ -30,7 +32,7 @@ nostd::shared_ptr ExemplarReservoir::GetAlignedHistogramBucke MapAndResetCellType map_and_reset_cell) { return nostd::shared_ptr{new AlignedHistogramBucketExemplarReservoir{ - size, reservoir_cell_selector, map_and_reset_cell}}; + size, std::move(reservoir_cell_selector), map_and_reset_cell}}; } nostd::shared_ptr ExemplarReservoir::GetNoExemplarReservoir() diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/deps/opentelemetry-cpp/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index f6ae47977d8..682badf3a4f 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -29,6 +28,10 @@ # include #endif +#if OPENTELEMETRY_HAVE_EXCEPTIONS +# include +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { @@ -90,31 +93,64 @@ void PeriodicExportingMetricReader::DoBackgroundWork() bool PeriodicExportingMetricReader::CollectAndExportOnce() { std::atomic cancel_export_for_timeout{false}; - auto future_receive = std::async(std::launch::async, [this, &cancel_export_for_timeout] { - Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) { - if (cancel_export_for_timeout) - { - OTEL_INTERNAL_LOG_ERROR( - "[Periodic Exporting Metric Reader] Collect took longer configured time: " - << export_timeout_millis_.count() << " ms, and timed out"); - return false; - } - this->exporter_->Export(metric_data); - return true; - }); - }); - std::future_status status; std::uint64_t notify_force_flush = force_flush_pending_sequence_.load(std::memory_order_acquire); - do + std::unique_ptr task_thread; + +#if OPENTELEMETRY_HAVE_EXCEPTIONS + try { - status = future_receive.wait_for(std::chrono::milliseconds(export_timeout_millis_)); - if (status == std::future_status::timeout) +#endif + std::promise sender; + auto receiver = sender.get_future(); + + task_thread.reset( + new std::thread([this, &cancel_export_for_timeout, sender = std::move(sender)] { + this->Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) { + if (cancel_export_for_timeout.load(std::memory_order_acquire)) + { + OTEL_INTERNAL_LOG_ERROR( + "[Periodic Exporting Metric Reader] Collect took longer configured time: " + << this->export_timeout_millis_.count() << " ms, and timed out"); + return false; + } + this->exporter_->Export(metric_data); + return true; + }); + + const_cast &>(sender).set_value(); + })); + + std::future_status status; + do { - cancel_export_for_timeout = true; - break; - } - } while (status != std::future_status::ready); + status = receiver.wait_for(std::chrono::milliseconds(export_timeout_millis_)); + if (status == std::future_status::timeout) + { + cancel_export_for_timeout.store(true, std::memory_order_release); + break; + } + } while (status != std::future_status::ready); +#if OPENTELEMETRY_HAVE_EXCEPTIONS + } + catch (std::exception &e) + { + OTEL_INTERNAL_LOG_ERROR("[Periodic Exporting Metric Reader] Collect failed with exception " + << e.what()); + return false; + } + catch (...) + { + OTEL_INTERNAL_LOG_ERROR( + "[Periodic Exporting Metric Reader] Collect failed with unknown exception"); + return false; + } +#endif + + if (task_thread && task_thread->joinable()) + { + task_thread->join(); + } std::uint64_t notified_sequence = force_flush_notified_sequence_.load(std::memory_order_acquire); while (notify_force_flush > notified_sequence) @@ -180,7 +216,7 @@ bool PeriodicExportingMetricReader::OnForceFlush(std::chrono::microseconds timeo // - If original `timeout` is `zero`, use that in exporter::forceflush // - Else if remaining `timeout_steady` more than zero, use that in exporter::forceflush // - Else don't invoke exporter::forceflush ( as remaining time is zero or less) - if (timeout <= std::chrono::steady_clock::duration::zero()) + if (timeout <= std::chrono::milliseconds::duration::zero()) { result = exporter_->ForceFlush(std::chrono::duration_cast(timeout)); diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/meter.cc b/deps/opentelemetry-cpp/sdk/src/metrics/meter.cc index f472ac726e2..c61f3a8d316 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/meter.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/meter.cc @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -54,7 +53,7 @@ Meter::Meter( std::weak_ptr meter_context, std::unique_ptr instrumentation_scope) noexcept : scope_{std::move(instrumentation_scope)}, - meter_context_{meter_context}, + meter_context_{std::move(meter_context)}, observable_registry_(new ObservableRegistry()) {} @@ -456,7 +455,7 @@ std::vector Meter::Collect(CollectorHandle *collector, for (auto &metric_storage : storage_registry_) { metric_storage.second->Collect(collector, ctx->GetCollectors(), ctx->GetSDKStartTime(), - collect_ts, [&metric_data_list](MetricData metric_data) { + collect_ts, [&metric_data_list](const MetricData &metric_data) { metric_data_list.push_back(metric_data); return true; }); diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/meter_context.cc b/deps/opentelemetry-cpp/sdk/src/metrics/meter_context.cc index de32c469d8f..15e689706a9 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/meter_context.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/meter_context.cc @@ -7,7 +7,6 @@ #include #include #include -#include #include #include @@ -36,7 +35,7 @@ namespace metrics { MeterContext::MeterContext(std::unique_ptr views, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept : resource_{resource}, views_(std::move(views)), sdk_start_ts_{std::chrono::system_clock::now()} {} @@ -82,7 +81,7 @@ opentelemetry::common::SystemTimestamp MeterContext::GetSDKStartTime() noexcept void MeterContext::AddMetricReader(std::shared_ptr reader) noexcept { - auto collector = std::shared_ptr{new MetricCollector(this, reader)}; + auto collector = std::shared_ptr{new MetricCollector(this, std::move(reader))}; collectors_.push_back(collector); } @@ -107,7 +106,7 @@ ExemplarFilterType MeterContext::GetExemplarFilter() const noexcept #endif // ENABLE_METRICS_EXEMPLAR_PREVIEW -void MeterContext::AddMeter(std::shared_ptr meter) +void MeterContext::AddMeter(const std::shared_ptr &meter) { std::lock_guard guard(meter_lock_); meters_.push_back(meter); @@ -168,46 +167,36 @@ bool MeterContext::ForceFlush(std::chrono::microseconds timeout) noexcept bool result = true; // Simultaneous flush not allowed. const std::lock_guard locked(forceflush_lock_); - // Convert to nanos to prevent overflow - auto timeout_ns = (std::chrono::nanoseconds::max)(); - if (std::chrono::duration_cast(timeout_ns) > timeout) - { - timeout_ns = std::chrono::duration_cast(timeout); - } - - auto current_time = std::chrono::system_clock::now(); - std::chrono::system_clock::time_point expire_time; - auto overflow_checker = (std::chrono::system_clock::time_point::max)(); - // check if the expected expire time doesn't overflow. - if (overflow_checker - current_time > timeout_ns) + auto time_remaining = (std::chrono::steady_clock::duration::max)(); + if (std::chrono::duration_cast(time_remaining) > timeout) { - expire_time = - current_time + std::chrono::duration_cast(timeout_ns); + time_remaining = timeout; } - else + + auto current_time = std::chrono::steady_clock::now(); + auto expire_time = (std::chrono::steady_clock::time_point::max)(); + if (expire_time - current_time > time_remaining) { - // overflow happens, reset expire time to max. - expire_time = overflow_checker; + expire_time = current_time + time_remaining; } for (auto &collector : collectors_) { if (!std::static_pointer_cast(collector)->ForceFlush( - std::chrono::duration_cast(timeout_ns))) + std::chrono::duration_cast(time_remaining))) { result = false; } - current_time = std::chrono::system_clock::now(); - + current_time = std::chrono::steady_clock::now(); if (expire_time >= current_time) { - timeout_ns = std::chrono::duration_cast(expire_time - current_time); + time_remaining = expire_time - current_time; } else { - timeout_ns = std::chrono::nanoseconds::zero(); + time_remaining = std::chrono::steady_clock::duration::zero(); } } if (!result) diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/meter_provider.cc b/deps/opentelemetry-cpp/sdk/src/metrics/meter_provider.cc index 959ff328001..4f2ca4b44f4 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/meter_provider.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/meter_provider.cc @@ -2,9 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include -#include #include #include "opentelemetry/common/key_value_iterable.h" @@ -39,7 +37,7 @@ MeterProvider::MeterProvider(std::unique_ptr context) noexcept {} MeterProvider::MeterProvider(std::unique_ptr views, - sdk::resource::Resource resource) noexcept + const sdk::resource::Resource &resource) noexcept : context_(std::make_shared(std::move(views), resource)) { OTEL_INTERNAL_LOG_DEBUG("[MeterProvider] MeterProvider created."); @@ -112,7 +110,7 @@ const resource::Resource &MeterProvider::GetResource() const noexcept void MeterProvider::AddMetricReader(std::shared_ptr reader) noexcept { - context_->AddMetricReader(reader); + context_->AddMetricReader(std::move(reader)); } void MeterProvider::AddView(std::unique_ptr instrument_selector, diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/meter_provider_factory.cc b/deps/opentelemetry-cpp/sdk/src/metrics/meter_provider_factory.cc index 7749a131248..c5e368aca6d 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/meter_provider_factory.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/meter_provider_factory.cc @@ -18,40 +18,6 @@ namespace sdk namespace metrics { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr MeterProviderFactory::Create() -{ - auto views = ViewRegistryFactory::Create(); - return Create(std::move(views)); -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr views) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(views), resource); -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr views, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new opentelemetry::sdk::metrics::MeterProvider(std::move(views), resource)); - return provider; -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new opentelemetry::sdk::metrics::MeterProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr MeterProviderFactory::Create() { auto views = ViewRegistryFactory::Create(); @@ -82,8 +48,6 @@ std::unique_ptr MeterProviderFactory return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace metrics } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/metric_reader.cc b/deps/opentelemetry-cpp/sdk/src/metrics/metric_reader.cc index e2f5bc1f1c9..024f91fe0fa 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/metric_reader.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/metric_reader.cc @@ -26,7 +26,7 @@ bool MetricReader::Collect( if (!metric_producer_) { OTEL_INTERNAL_LOG_WARN( - "MetricReader::Collect Cannot invoke Collect(). No MetricProducer registered for " + "MetricReader::Collect Cannot invoke Produce(). No MetricProducer registered for " "collection!") return false; } @@ -36,7 +36,15 @@ bool MetricReader::Collect( OTEL_INTERNAL_LOG_WARN("MetricReader::Collect invoked while Shutdown in progress!"); } - return metric_producer_->Collect(callback); + auto result = metric_producer_->Produce(); + + // According to the spec, + // When the Produce operation fails, the MetricProducer MAY return successfully collected + // results and a failed reasons list to the caller. + // So we invoke the callback with whatever points we get back, even if the overall operation may + // have failed. + auto success = callback(result.points_); + return (result.status_ == MetricProducer::Status::kSuccess) && success; } bool MetricReader::Shutdown(std::chrono::microseconds timeout) noexcept diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/state/metric_collector.cc b/deps/opentelemetry-cpp/sdk/src/metrics/state/metric_collector.cc index 5ecf41cecfb..2a799b7fda5 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/state/metric_collector.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/state/metric_collector.cc @@ -24,10 +24,11 @@ namespace sdk { namespace metrics { +using opentelemetry::sdk::resource::Resource; MetricCollector::MetricCollector(opentelemetry::sdk::metrics::MeterContext *context, std::shared_ptr metric_reader) - : meter_context_{context}, metric_reader_{metric_reader} + : meter_context_{context}, metric_reader_{std::move(metric_reader)} { metric_reader_->SetMetricProducer(this); } @@ -38,17 +39,16 @@ AggregationTemporality MetricCollector::GetAggregationTemporality( return metric_reader_->GetAggregationTemporality(instrument_type); } -bool MetricCollector::Collect( - nostd::function_ref callback) noexcept +MetricProducer::Result MetricCollector::Produce() noexcept { if (!meter_context_) { OTEL_INTERNAL_LOG_ERROR("[MetricCollector::Collect] - Error during collecting." << "The metric context is invalid"); - return false; + return {{}, MetricProducer::Status::kFailure}; } ResourceMetrics resource_metrics; - meter_context_->ForEachMeter([&](std::shared_ptr meter) noexcept { + meter_context_->ForEachMeter([&](const std::shared_ptr &meter) noexcept { auto collection_ts = std::chrono::system_clock::now(); auto metric_data = meter->Collect(this, collection_ts); if (!metric_data.empty()) @@ -61,8 +61,7 @@ bool MetricCollector::Collect( return true; }); resource_metrics.resource_ = &meter_context_->GetResource(); - callback(resource_metrics); - return true; + return {resource_metrics, MetricProducer::Status::kSuccess}; } bool MetricCollector::ForceFlush(std::chrono::microseconds timeout) noexcept diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/state/observable_registry.cc b/deps/opentelemetry-cpp/sdk/src/metrics/state/observable_registry.cc index 4da46ddfe32..8db11d4605b 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/state/observable_registry.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/state/observable_registry.cc @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/state/sync_metric_storage.cc b/deps/opentelemetry-cpp/sdk/src/metrics/state/sync_metric_storage.cc index fe736e64f3c..ad6ea278213 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/state/sync_metric_storage.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/state/sync_metric_storage.cc @@ -39,7 +39,7 @@ bool SyncMetricStorage::Collect(CollectorHandle *collector, } return temporal_metric_storage_.buildMetrics(collector, collectors, sdk_start_ts, collection_ts, - std::move(delta_metrics), callback); + delta_metrics, callback); } } // namespace metrics diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/state/temporal_metric_storage.cc b/deps/opentelemetry-cpp/sdk/src/metrics/state/temporal_metric_storage.cc index 2ba74d9213f..c26339a79fb 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/state/temporal_metric_storage.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/state/temporal_metric_storage.cc @@ -35,7 +35,7 @@ namespace metrics TemporalMetricStorage::TemporalMetricStorage(InstrumentDescriptor instrument_descriptor, AggregationType aggregation_type, const AggregationConfig *aggregation_config) - : instrument_descriptor_(instrument_descriptor), + : instrument_descriptor_(std::move(instrument_descriptor)), aggregation_type_(aggregation_type), aggregation_config_(aggregation_config) {} @@ -44,7 +44,7 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector, nostd::span> collectors, opentelemetry::common::SystemTimestamp sdk_start_ts, opentelemetry::common::SystemTimestamp collection_ts, - std::shared_ptr delta_metrics, + const std::shared_ptr &delta_metrics, nostd::function_ref callback) noexcept { std::lock_guard guard(lock_); diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/sync_instruments.cc b/deps/opentelemetry-cpp/sdk/src/metrics/sync_instruments.cc index a99fa808688..56429a079f9 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/sync_instruments.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/sync_instruments.cc @@ -20,7 +20,7 @@ namespace sdk { namespace metrics { -LongCounter::LongCounter(InstrumentDescriptor instrument_descriptor, +LongCounter::LongCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -80,7 +80,7 @@ void LongCounter::Add(uint64_t value, const opentelemetry::context::Context &con return storage_->RecordLong(value, context); } -DoubleCounter::DoubleCounter(InstrumentDescriptor instrument_descriptor, +DoubleCounter::DoubleCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -164,7 +164,7 @@ void DoubleCounter::Add(double value, const opentelemetry::context::Context &con return storage_->RecordDouble(value, context); } -LongUpDownCounter::LongUpDownCounter(InstrumentDescriptor instrument_descriptor, +LongUpDownCounter::LongUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -228,7 +228,7 @@ void LongUpDownCounter::Add(int64_t value, const opentelemetry::context::Context return storage_->RecordLong(value, context); } -DoubleUpDownCounter::DoubleUpDownCounter(InstrumentDescriptor instrument_descriptor, +DoubleUpDownCounter::DoubleUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -292,7 +292,7 @@ void DoubleUpDownCounter::Add(double value, const opentelemetry::context::Contex return storage_->RecordDouble(value, context); } -LongHistogram::LongHistogram(InstrumentDescriptor instrument_descriptor, +LongHistogram::LongHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -355,7 +355,7 @@ void LongHistogram::Record(uint64_t value) noexcept } #endif -DoubleHistogram::DoubleHistogram(InstrumentDescriptor instrument_descriptor, +DoubleHistogram::DoubleHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/view/view_factory.cc b/deps/opentelemetry-cpp/sdk/src/metrics/view/view_factory.cc index 36496f62d65..319c10b956b 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/view/view_factory.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/view/view_factory.cc @@ -53,7 +53,7 @@ std::unique_ptr ViewFactory::Create(const std::string &name, auto attributes_processor = std::unique_ptr(new DefaultAttributesProcessor()); - return Create(name, description, unit, aggregation_type, aggregation_config, + return Create(name, description, unit, aggregation_type, std::move(aggregation_config), std::move(attributes_processor)); } @@ -64,7 +64,8 @@ std::unique_ptr ViewFactory::Create(const std::string &name, std::shared_ptr aggregation_config, std::unique_ptr attributes_processor) { - std::unique_ptr view(new View(name, description, unit, aggregation_type, aggregation_config, + std::unique_ptr view(new View(name, description, unit, aggregation_type, + std::move(aggregation_config), std::move(attributes_processor))); return view; } diff --git a/deps/opentelemetry-cpp/sdk/src/trace/batch_span_processor.cc b/deps/opentelemetry-cpp/sdk/src/trace/batch_span_processor.cc index c5e72f81760..f0f55d20e8a 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/batch_span_processor.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/batch_span_processor.cc @@ -29,7 +29,6 @@ #include "opentelemetry/version.h" using opentelemetry::sdk::common::AtomicUniquePtr; -using opentelemetry::sdk::common::CircularBuffer; using opentelemetry::sdk::common::CircularBufferRange; using opentelemetry::trace::SpanContext; @@ -67,7 +66,7 @@ void BatchSpanProcessor::OnEnd(std::unique_ptr &&span) noexcept return; } - if (buffer_.Add(span) == false) + if (buffer_.Add(std::move(span)) == false) { OTEL_INTERNAL_LOG_WARN("BatchSpanProcessor queue is full - dropping span."); return; @@ -206,6 +205,10 @@ void BatchSpanProcessor::Export() NotifyCompletion(notify_force_flush, exporter_, synchronization_data_); break; } + + // Reserve space for the number of records + spans_arr.reserve(num_records_to_export); + buffer_.Consume(num_records_to_export, [&](CircularBufferRange> range) noexcept { range.ForEach([&](AtomicUniquePtr &ptr) { diff --git a/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent.cc b/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent.cc index a69ede92d4e..9bffb7b030a 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent.cc @@ -22,7 +22,7 @@ namespace sdk { namespace trace { -ParentBasedSampler::ParentBasedSampler(std::shared_ptr delegate_sampler) noexcept +ParentBasedSampler::ParentBasedSampler(const std::shared_ptr &delegate_sampler) noexcept : delegate_sampler_(delegate_sampler), description_("ParentBased{" + std::string{delegate_sampler->GetDescription()} + "}") {} diff --git a/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent_factory.cc b/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent_factory.cc index 978fb75946d..25a2e94f653 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent_factory.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent_factory.cc @@ -1,8 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/samplers/parent_factory.h" +#include + +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/parent.h" +#include "opentelemetry/sdk/trace/samplers/parent_factory.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,7 +15,7 @@ namespace trace { std::unique_ptr ParentBasedSamplerFactory::Create( - std::shared_ptr delegate_sampler) + const std::shared_ptr &delegate_sampler) { std::unique_ptr sampler(new ParentBasedSampler(delegate_sampler)); return sampler; diff --git a/deps/opentelemetry-cpp/sdk/src/trace/span.cc b/deps/opentelemetry-cpp/sdk/src/trace/span.cc index ca3a4757077..2b9e9d29088 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/span.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/span.cc @@ -78,7 +78,7 @@ Span::Span(std::shared_ptr &&tracer, return true; }); - links.ForEachKeyValue([&](opentelemetry::trace::SpanContext span_context, + links.ForEachKeyValue([&](const opentelemetry::trace::SpanContext &span_context, const common::KeyValueIterable &attributes) { recordable_->AddLink(span_context, attributes); return true; diff --git a/deps/opentelemetry-cpp/sdk/src/trace/tracer.cc b/deps/opentelemetry-cpp/sdk/src/trace/tracer.cc index f23ce5f6280..73fc08d5dc9 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/tracer.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/tracer.cc @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -12,7 +11,6 @@ #include "opentelemetry/context/context.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/trace/id_generator.h" @@ -41,7 +39,7 @@ namespace trace Tracer::Tracer(std::shared_ptr context, std::unique_ptr instrumentation_scope) noexcept - : instrumentation_scope_{std::move(instrumentation_scope)}, context_{context} + : instrumentation_scope_{std::move(instrumentation_scope)}, context_{std::move(context)} {} nostd::shared_ptr Tracer::StartSpan( diff --git a/deps/opentelemetry-cpp/sdk/src/trace/tracer_context.cc b/deps/opentelemetry-cpp/sdk/src/trace/tracer_context.cc index 0fb4fd35cf9..65300d6f22b 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/tracer_context.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/tracer_context.cc @@ -22,7 +22,7 @@ namespace trace namespace resource = opentelemetry::sdk::resource; TracerContext::TracerContext(std::vector> &&processors, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept : resource_(resource), diff --git a/deps/opentelemetry-cpp/sdk/src/trace/tracer_provider.cc b/deps/opentelemetry-cpp/sdk/src/trace/tracer_provider.cc index 7421e07de4d..3b5462a0839 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/tracer_provider.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/tracer_provider.cc @@ -3,9 +3,7 @@ #include #include -#include #include -#include #include #include @@ -40,7 +38,7 @@ TracerProvider::TracerProvider(std::unique_ptr context) noexcept } TracerProvider::TracerProvider(std::unique_ptr processor, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept { @@ -51,7 +49,7 @@ TracerProvider::TracerProvider(std::unique_ptr processor, } TracerProvider::TracerProvider(std::vector> &&processors, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept { diff --git a/deps/opentelemetry-cpp/sdk/src/trace/tracer_provider_factory.cc b/deps/opentelemetry-cpp/sdk/src/trace/tracer_provider_factory.cc index eeb18a1e593..eaeb669b91b 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/tracer_provider_factory.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/tracer_provider_factory.cc @@ -22,90 +22,6 @@ namespace sdk namespace trace { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processor), resource); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource) -{ - auto sampler = AlwaysOnSamplerFactory::Create(); - return Create(std::move(processor), resource, std::move(sampler)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler) -{ - auto id_generator = RandomIdGeneratorFactory::Create(); - return Create(std::move(processor), resource, std::move(sampler), std::move(id_generator)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(processor), resource, - std::move(sampler), std::move(id_generator))); - return provider; -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processors), resource); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource) -{ - auto sampler = AlwaysOnSamplerFactory::Create(); - return Create(std::move(processors), resource, std::move(sampler)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler) -{ - auto id_generator = RandomIdGeneratorFactory::Create(); - return Create(std::move(processors), resource, std::move(sampler), std::move(id_generator)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(processors), resource, - std::move(sampler), std::move(id_generator))); - return provider; -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr TracerProviderFactory::Create( std::unique_ptr processor) { @@ -186,8 +102,6 @@ std::unique_ptr TracerProviderFactory return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/version/version.cc b/deps/opentelemetry-cpp/sdk/src/version/version.cc index e5fdbda99d2..97e7f15549f 100644 --- a/deps/opentelemetry-cpp/sdk/src/version/version.cc +++ b/deps/opentelemetry-cpp/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 16; +const int minor_version = 17; const int patch_version = 0; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.16.0"; -const char *full_version = "1.16.0-NONE-NONE"; -const char *build_date = "Fri Jun 21 16:41:17 UTC 2024"; +const char *short_version = "1.17.0"; +const char *full_version = "1.17.0-NONE-NONE"; +const char *build_date = "Mon Oct 7 08:55:12 PM UTC 2024"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc b/deps/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc index b7ef17244f7..9b1f6bd56e4 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc @@ -1,13 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/attribute_utils.h" - #include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attribute_utils.h" TEST(AttributeMapTest, DefaultConstruction) { - opentelemetry::sdk::common::AttributeMap attribute_map; EXPECT_EQ(attribute_map.GetAttributes().size(), 0); } diff --git a/deps/opentelemetry-cpp/sdk/test/common/attributemap_hash_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/common/attributemap_hash_benchmark.cc index 811ecb23dd0..e0641fb961e 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/attributemap_hash_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/attributemap_hash_benchmark.cc @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #include + +#include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/common/attributemap_hash.h" using namespace opentelemetry::sdk::common; diff --git a/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_benchmark.cc index 1f2b9b42cf7..7ffc4521355 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_benchmark.cc @@ -1,18 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "benchmark/benchmark.h" - +#include #include #include +#include +#include #include #include #include #include #include +#include "benchmark/benchmark.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" #include "opentelemetry/sdk/common/circular_buffer.h" +#include "opentelemetry/sdk/common/circular_buffer_range.h" #include "test/common/baseline_circular_buffer.h" + using opentelemetry::sdk::common::AtomicUniquePtr; using opentelemetry::sdk::common::CircularBuffer; using opentelemetry::sdk::common::CircularBufferRange; diff --git a/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_range_test.cc b/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_range_test.cc index 58527046879..ed2f0289786 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_range_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_range_test.cc @@ -1,11 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/circular_buffer_range.h" +#include -#include +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/circular_buffer_range.h" -#include using opentelemetry::sdk::common::CircularBufferRange; TEST(CircularBufferRangeTest, ForEach) diff --git a/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_test.cc b/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_test.cc index a20c3e42aa3..8a3292ca605 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/circular_buffer_test.cc @@ -1,14 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/circular_buffer.h" - +#include +#include #include +#include #include +#include +#include +#include +#include #include #include +#include + +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" +#include "opentelemetry/sdk/common/circular_buffer.h" +#include "opentelemetry/sdk/common/circular_buffer_range.h" -#include using opentelemetry::sdk::common::AtomicUniquePtr; using opentelemetry::sdk::common::CircularBuffer; using opentelemetry::sdk::common::CircularBufferRange; diff --git a/deps/opentelemetry-cpp/sdk/test/common/empty_attributes_test.cc b/deps/opentelemetry-cpp/sdk/test/common/empty_attributes_test.cc index f37ea0a5c47..894cafc8a7d 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/empty_attributes_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/empty_attributes_test.cc @@ -15,5 +15,5 @@ TEST(EmptyAttributesTest, TestMemory) { auto attributes1 = opentelemetry::sdk::GetEmptyAttributes(); auto attributes2 = opentelemetry::sdk::GetEmptyAttributes(); - EXPECT_EQ(memcmp(&attributes1, &attributes2, sizeof(attributes1)), 0); + EXPECT_EQ(memcmp(&attributes1, &attributes2, sizeof(attributes1)), 0); // NOLINT } diff --git a/deps/opentelemetry-cpp/sdk/test/common/env_var_test.cc b/deps/opentelemetry-cpp/sdk/test/common/env_var_test.cc index 23d3802361a..8f64dc1f103 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/env_var_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/env_var_test.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/env_variables.h" - #include +#include +#include +#include + +#include "opentelemetry/sdk/common/env_variables.h" #if defined(_MSC_VER) using opentelemetry::sdk::common::setenv; diff --git a/deps/opentelemetry-cpp/sdk/test/common/fast_random_number_generator_test.cc b/deps/opentelemetry-cpp/sdk/test/common/fast_random_number_generator_test.cc index e9209fdb6bf..1f87ea13d75 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/fast_random_number_generator_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/fast_random_number_generator_test.cc @@ -1,11 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "src/common/random.h" - +#include +#include #include +#include +#include -#include +#include "src/common/fast_random_number_generator.h" using opentelemetry::sdk::common::FastRandomNumberGenerator; diff --git a/deps/opentelemetry-cpp/sdk/test/common/global_log_handle_test.cc b/deps/opentelemetry-cpp/sdk/test/common/global_log_handle_test.cc index 28b111cc716..3c3fc3d7f38 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/global_log_handle_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/global_log_handle_test.cc @@ -1,12 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/common/global_log_handler.h" - #include - #include +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" + class CustomLogHandler : public opentelemetry::sdk::common::internal_log::LogHandler { public: diff --git a/deps/opentelemetry-cpp/sdk/test/common/random_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/common/random_benchmark.cc index df2ebf95ec0..46dadbe260b 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/random_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/random_benchmark.cc @@ -1,12 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "src/common/random.h" - -#include +#include #include -#include +#include "src/common/random.h" namespace { diff --git a/deps/opentelemetry-cpp/sdk/test/common/random_fork_test.cc b/deps/opentelemetry-cpp/sdk/test/common/random_fork_test.cc index 2db8b9fcdff..15f7a43cf27 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/random_fork_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/random_fork_test.cc @@ -7,13 +7,13 @@ // See https://github.com/opentracing-contrib/nginx-opentracing/issues/52 # include "src/common/random.h" +# include # include -# include # include # include -# include # include # include + using opentelemetry::sdk::common::Random; static uint64_t *child_id; diff --git a/deps/opentelemetry-cpp/sdk/test/common/random_test.cc b/deps/opentelemetry-cpp/sdk/test/common/random_test.cc index 8132b2d5a47..85292babe43 100644 --- a/deps/opentelemetry-cpp/sdk/test/common/random_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/common/random_test.cc @@ -1,12 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "src/common/random.h" - +#include #include +#include +#include +#include #include +#include +#include + +#include "src/common/random.h" -#include using opentelemetry::sdk::common::Random; TEST(RandomTest, GenerateRandom64) @@ -34,3 +39,28 @@ TEST(RandomTest, GenerateRandomBuffer) std::equal(std::begin(buf1_vector), std::end(buf1_vector), std::begin(buf2_vector))); } } + +void doSomethingOnce(std::atomic_uint *count) +{ + static std::atomic_flag flag; + if (!flag.test_and_set()) + { + (*count)++; + } +} + +TEST(RandomTest, AtomicFlagMultiThreadTest) +{ + std::vector threads; + std::atomic_uint count(0); + threads.reserve(10); + for (int i = 0; i < 10; ++i) + { + threads.push_back(std::thread(doSomethingOnce, &count)); + } + for (auto &t : threads) + { + t.join(); + } + EXPECT_EQ(1, count.load()); +} diff --git a/deps/opentelemetry-cpp/sdk/test/instrumentationscope/instrumentationscope_test.cc b/deps/opentelemetry-cpp/sdk/test/instrumentationscope/instrumentationscope_test.cc index 2f376d5d6b5..da00ec8e93a 100644 --- a/deps/opentelemetry-cpp/sdk/test/instrumentationscope/instrumentationscope_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/instrumentationscope/instrumentationscope_test.cc @@ -1,15 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h" -#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" - #include +#include +#include #include #include +#include #include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" + using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/deps/opentelemetry-cpp/sdk/test/logs/batch_log_record_processor_test.cc b/deps/opentelemetry-cpp/sdk/test/logs/batch_log_record_processor_test.cc index 33db0da4792..036146f4e64 100644 --- a/deps/opentelemetry-cpp/sdk/test/logs/batch_log_record_processor_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/logs/batch_log_record_processor_test.cc @@ -1,14 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/batch_log_record_processor.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/recordable.h" - #include +#include +#include #include +#include #include +#include #include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/recordable.h" using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; @@ -74,10 +91,10 @@ class MockLogExporter final : public LogRecordExporter std::shared_ptr> is_shutdown, std::shared_ptr> is_export_completed, const std::chrono::milliseconds export_delay = std::chrono::milliseconds(0)) - : logs_received_(logs_received), - force_flush_counter_(force_flush_counter), - is_shutdown_(is_shutdown), - is_export_completed_(is_export_completed), + : logs_received_(std::move(logs_received)), + force_flush_counter_(std::move(force_flush_counter)), + is_shutdown_(std::move(is_shutdown)), + is_export_completed_(std::move(is_export_completed)), export_delay_(export_delay) {} @@ -154,7 +171,8 @@ class BatchLogRecordProcessorTest : public testing::Test // ::testing::Test { return std::shared_ptr(new BatchLogRecordProcessor( std::unique_ptr(new MockLogExporter( - logs_received, force_flush_counter, is_shutdown, is_export_completed, export_delay)), + std::move(logs_received), std::move(force_flush_counter), std::move(is_shutdown), + std::move(is_export_completed), export_delay)), max_queue_size, scheduled_delay_millis, max_export_batch_size)); } }; diff --git a/deps/opentelemetry-cpp/sdk/test/logs/log_record_test.cc b/deps/opentelemetry-cpp/sdk/test/logs/log_record_test.cc index bd9e4620120..99ba9f296d1 100644 --- a/deps/opentelemetry-cpp/sdk/test/logs/log_record_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/logs/log_record_test.cc @@ -1,21 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include -#include +#include +#include #include -#include +#include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/event_id.h" +#include "opentelemetry/logs/log_record.h" #include "opentelemetry/logs/logger.h" -#include "opentelemetry/logs/provider.h" +#include "opentelemetry/logs/logger_provider.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/logs/read_write_log_record.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" -#include - using opentelemetry::sdk::logs::ReadWriteLogRecord; namespace trace_api = opentelemetry::trace; namespace logs_api = opentelemetry::logs; diff --git a/deps/opentelemetry-cpp/sdk/test/logs/logger_provider_sdk_test.cc b/deps/opentelemetry-cpp/sdk/test/logs/logger_provider_sdk_test.cc index ecb9ea6f9c1..a5a3d3a68ad 100644 --- a/deps/opentelemetry-cpp/sdk/test/logs/logger_provider_sdk_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/logs/logger_provider_sdk_test.cc @@ -1,20 +1,38 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include +#include +#include +#include +#include #include +#include +#include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/provider.h" +#include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/logs/event_logger_provider.h" #include "opentelemetry/sdk/logs/event_logger_provider_factory.h" #include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/logger.h" +#include "opentelemetry/sdk/logs/logger_context.h" #include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/sdk/logs/simple_log_record_processor.h" - -#include +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" using namespace opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; diff --git a/deps/opentelemetry-cpp/sdk/test/logs/logger_sdk_test.cc b/deps/opentelemetry-cpp/sdk/test/logs/logger_sdk_test.cc index 62d523b92a1..4af0fb37457 100644 --- a/deps/opentelemetry-cpp/sdk/test/logs/logger_sdk_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/logs/logger_sdk_test.cc @@ -1,25 +1,44 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include #include #include - +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/event_logger.h" +#include "opentelemetry/logs/event_logger_provider.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger.h" #include "opentelemetry/logs/logger_provider.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/event_logger.h" #include "opentelemetry/sdk/logs/event_logger_provider.h" #include "opentelemetry/sdk/logs/logger.h" #include "opentelemetry/sdk/logs/logger_provider.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" #include "opentelemetry/trace/tracer.h" -#include - using namespace opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; namespace nostd = opentelemetry::nostd; @@ -172,7 +191,7 @@ class MockProcessor final : public LogRecordProcessor public: // A processor used for testing that keeps a track of the recordable it received explicit MockProcessor(std::shared_ptr record_received) noexcept - : record_received_(record_received) + : record_received_(std::move(record_received)) {} std::unique_ptr MakeRecordable() noexcept override diff --git a/deps/opentelemetry-cpp/sdk/test/logs/simple_log_record_processor_test.cc b/deps/opentelemetry-cpp/sdk/test/logs/simple_log_record_processor_test.cc index 484cc63e71d..b8a9f03e0c8 100644 --- a/deps/opentelemetry-cpp/sdk/test/logs/simple_log_record_processor_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/logs/simple_log_record_processor_test.cc @@ -1,15 +1,26 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/simple_log_record_processor.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/recordable.h" - -#include - -#include -#include +#include "opentelemetry/sdk/logs/simple_log_record_processor.h" using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; @@ -75,7 +86,7 @@ class TestExporter final : public LogRecordExporter size_t *batch_size_received) : force_flush_counter_(force_flush_counter), shutdown_counter_(shutdown_counter), - logs_received_(logs_received), + logs_received_(std::move(logs_received)), batch_size_received(batch_size_received) {} diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/BUILD b/deps/opentelemetry-cpp/sdk/test/metrics/BUILD index 3cf379494dd..70d0cc063a9 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/BUILD +++ b/deps/opentelemetry-cpp/sdk/test/metrics/BUILD @@ -19,307 +19,8 @@ cc_library( ) cc_test( - name = "meter_test", - srcs = [ - "meter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "meter_provider_sdk_test", - srcs = [ - "meter_provider_sdk_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "metric_reader_test", - srcs = [ - "metric_reader_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "histogram_test", - srcs = [ - "histogram_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "view_registry_test", - srcs = [ - "view_registry_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "aggregation_test", - srcs = [ - "aggregation_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_counter_test", - srcs = [ - "sync_metric_storage_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_up_down_counter_test", - srcs = [ - "sync_metric_storage_up_down_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_metric_storage_histogram_test", - srcs = [ - "sync_metric_storage_histogram_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sync_instruments_test", - srcs = [ - "sync_instruments_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "async_instruments_test", - srcs = [ - "async_instruments_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "async_metric_storage_test", - srcs = [ - "async_metric_storage_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "observer_result_test", - srcs = [ - "observer_result_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "multi_metric_storage_test", - srcs = [ - "multi_metric_storage_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "//sdk/src/resource", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "attributes_processor_test", - srcs = [ - "attributes_processor_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "attributes_hashmap_test", - srcs = [ - "attributes_hashmap_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "circular_buffer_counter_test", - srcs = [ - "circular_buffer_counter_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "//sdk/src/metrics", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "base2_exponential_histogram_indexer_test", - srcs = [ - "base2_exponential_histogram_indexer_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "histogram_aggregation_test", - srcs = [ - "histogram_aggregation_test.cc", - ], - tags = [ - "metrics", - "test", - ], - deps = [ - "metrics_common_test_utils", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "sum_aggregation_test", - srcs = [ - "sum_aggregation_test.cc", - ], + name = "all_tests", + srcs = glob(["*_test.cc"]), tags = [ "metrics", "test", diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/aggregation_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/aggregation_test.cc index d52cc9e732c..d56f33545a7 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/aggregation_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/aggregation_test.cc @@ -2,13 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include + +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/sum_aggregation.h" - -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" using namespace opentelemetry::sdk::metrics; namespace nostd = opentelemetry::nostd; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/async_instruments_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/async_instruments_test.cc index 10c03355593..cda08a15495 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/async_instruments_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/async_instruments_test.cc @@ -1,20 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/metrics/observer_result.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/sdk/metrics/async_instruments.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" #include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" #include "opentelemetry/sdk/metrics/state/observable_registry.h" -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::metrics; using M = std::map; +namespace +{ +// NOLINTNEXTLINE void asyc_generate_measurements(opentelemetry::metrics::ObserverResult /* observer */, void * /* state */) {} +} // namespace TEST(AsyncInstruments, ObservableInstrument) { diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/async_metric_storage_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/async_metric_storage_test.cc index 3b72e99d96a..912310415ac 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/async_metric_storage_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/async_metric_storage_test.cc @@ -1,30 +1,37 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/sdk/metrics/async_instruments.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/async_metric_storage.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif -#include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/meter_context.h" -#include "opentelemetry/sdk/metrics/metric_reader.h" -#include "opentelemetry/sdk/metrics/observer_result.h" -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" -#include "opentelemetry/sdk/metrics/state/async_metric_storage.h" -#include "opentelemetry/sdk/metrics/state/metric_collector.h" -#include "opentelemetry/sdk/metrics/state/observable_registry.h" - -#include -#include -#include -#include - using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::resource; @@ -262,7 +269,7 @@ TEST_P(WritableMetricStorageTestObservableGaugeFixture, TestAggregation) opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now())); storage.Collect( - collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) { + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { for (auto data_attr : metric_data.point_data_attr_) { auto data = opentelemetry::nostd::get(data_attr.point_data); @@ -288,7 +295,7 @@ TEST_P(WritableMetricStorageTestObservableGaugeFixture, TestAggregation) storage.RecordLong(measurements2, opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now())); storage.Collect( - collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) { + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { for (auto data_attr : metric_data.point_data_attr_) { auto data = opentelemetry::nostd::get(data_attr.point_data); diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_benchmark.cc index 5dc02ca5bed..ed080d911d2 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_benchmark.cc @@ -2,17 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include "opentelemetry/sdk/common/attributemap_hash.h" -#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" -#include "opentelemetry/sdk/metrics/aggregation/drop_aggregation.h" -#include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" - +#include +#include +#include #include +#include #include #include #include +#include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/drop_aggregation.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" + using namespace opentelemetry::sdk::metrics; constexpr size_t MAX_THREADS = 500; namespace diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_test.cc index 7e03deed47f..c7f0f01ee53 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_test.cc @@ -1,19 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include -#include "opentelemetry/sdk/metrics/aggregation/drop_aggregation.h" -#include "opentelemetry/sdk/metrics/instruments.h" - +#include +#include #include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/drop_aggregation.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" using namespace opentelemetry::sdk::metrics; namespace nostd = opentelemetry::nostd; TEST(AttributesHashMap, BasicTests) { - // Empty map AttributesHashMap hash_map; EXPECT_EQ(hash_map.Size(), 0); @@ -27,14 +38,14 @@ TEST(AttributesHashMap, BasicTests) std::unique_ptr aggregation1( new DropAggregation()); // = std::unique_ptr(new DropAggregation); hash_map.Set(m1, std::move(aggregation1), hash); - EXPECT_NO_THROW(hash_map.Get(hash)->Aggregate(static_cast(1))); + hash_map.Get(hash)->Aggregate(static_cast(1)); EXPECT_EQ(hash_map.Size(), 1); EXPECT_EQ(hash_map.Has(hash), true); // Set same key again auto aggregation2 = std::unique_ptr(new DropAggregation()); hash_map.Set(m1, std::move(aggregation2), hash); - EXPECT_NO_THROW(hash_map.Get(hash)->Aggregate(static_cast(1))); + hash_map.Get(hash)->Aggregate(static_cast(1)); EXPECT_EQ(hash_map.Size(), 1); EXPECT_EQ(hash_map.Has(hash), true); @@ -45,7 +56,7 @@ TEST(AttributesHashMap, BasicTests) hash_map.Set(m3, std::move(aggregation3), hash3); EXPECT_EQ(hash_map.Has(hash), true); EXPECT_EQ(hash_map.Has(hash3), true); - EXPECT_NO_THROW(hash_map.Get(hash3)->Aggregate(static_cast(1))); + hash_map.Get(hash3)->Aggregate(static_cast(1)); EXPECT_EQ(hash_map.Size(), 2); // GetOrSetDefault @@ -55,8 +66,8 @@ TEST(AttributesHashMap, BasicTests) }; MetricAttributes m4 = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}}; auto hash4 = opentelemetry::sdk::common::GetHashForAttributeMap(m4); - EXPECT_NO_THROW(hash_map.GetOrSetDefault(m4, create_default_aggregation, hash4) - ->Aggregate(static_cast(1))); + hash_map.GetOrSetDefault(m4, create_default_aggregation, hash4) + ->Aggregate(static_cast(1)); EXPECT_EQ(hash_map.Size(), 3); // Set attributes with different order - shouldn't create a new entry. @@ -73,3 +84,78 @@ TEST(AttributesHashMap, BasicTests) }); EXPECT_EQ(count, hash_map.Size()); } + +std::string make_unique_string(const char *str) +{ + return std::string(str); +} + +TEST(AttributesHashMap, HashWithKeyValueIterable) +{ + std::string key1 = make_unique_string("k1"); + std::string value1 = make_unique_string("v1"); + std::string key2 = make_unique_string("k2"); + std::string value2 = make_unique_string("v2"); + std::string key3 = make_unique_string("k3"); + std::string value3 = make_unique_string("v3"); + + // Create mock KeyValueIterable instances with the same content but different variables + std::map attributes1({{key1, value1}, {key2, value2}}); + std::map attributes2({{key1, value1}, {key2, value2}}); + std::map attributes3({{key1, value1}, {key2, value2}, {key3, value3}}); + + // Create a callback that filters "k3" key + auto is_key_filter_k3_callback = [](nostd::string_view key) { + if (key == "k3") + { + return false; + } + return true; + }; + // Calculate hash + size_t hash1 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes1), + is_key_filter_k3_callback); + size_t hash2 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes2), + is_key_filter_k3_callback); + + size_t hash3 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes3), + is_key_filter_k3_callback); + + // Expect the hashes to be the same because the content is the same + EXPECT_EQ(hash1, hash2); + // Expect the hashes to be the same because the content is the same + EXPECT_EQ(hash1, hash3); +} + +TEST(AttributesHashMap, HashConsistencyAcrossStringTypes) +{ + const char *c_str = "teststring"; + std::string std_str = "teststring"; + nostd::string_view nostd_str_view = "teststring"; +#if __cplusplus >= 201703L + std::string_view std_str_view = "teststring"; +#endif + + size_t hash_c_str = 0; + size_t hash_std_str = 0; + size_t hash_nostd_str_view = 0; +#if __cplusplus >= 201703L + size_t hash_std_str_view = 0; +#endif + + opentelemetry::sdk::common::GetHash(hash_c_str, c_str); + opentelemetry::sdk::common::GetHash(hash_std_str, std_str); + opentelemetry::sdk::common::GetHash(hash_nostd_str_view, nostd_str_view); +#if __cplusplus >= 201703L + opentelemetry::sdk::common::GetHash(hash_std_str_view, std_str_view); +#endif + + EXPECT_EQ(hash_c_str, hash_std_str); + EXPECT_EQ(hash_c_str, hash_nostd_str_view); +#if __cplusplus >= 201703L + EXPECT_EQ(hash_c_str, hash_std_str_view); +#endif +} diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_benchmark.cc index 28f1984b403..708549406bf 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_benchmark.cc @@ -3,7 +3,12 @@ #include #include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" + using namespace opentelemetry::sdk::metrics; namespace { diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_test.cc index 62c0879ca92..5299af13587 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_test.cc @@ -1,8 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc index 9f1d0d864de..40ea14d5751 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc @@ -1,12 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h" - #include +#include #include #include +#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h" + using namespace opentelemetry::sdk::metrics; namespace { diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc index 85f6fe72e9f..716985e7cf7 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc @@ -1,9 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h" - #include +#include +#include + +#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h" using namespace opentelemetry::sdk::metrics; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/cardinality_limit_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/cardinality_limit_test.cc index 8c2edb4b0c7..926062709b2 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/cardinality_limit_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/cardinality_limit_test.cc @@ -1,18 +1,39 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" + +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/sum_aggregation.h" -#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" -#endif +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#include -#include +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +#endif using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; @@ -26,7 +47,7 @@ TEST(CardinalityLimit, AttributesHashMapBasicTests) return std::unique_ptr(new LongSumAggregation(true)); }; // add 10 unique metric points. 9 should be added to hashmap, 10th should be overflow. - long record_value = 100; + int64_t record_value = 100; for (auto i = 0; i < 10; i++) { FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; @@ -47,14 +68,47 @@ TEST(CardinalityLimit, AttributesHashMapBasicTests) ->Aggregate(record_value); } EXPECT_EQ(hash_map.Size(), 10); // only one more metric point should be added as overflow. + // record 5 more measurements to already existing (and not-overflow) metric points. They + // should get aggregated to these existing metric points. + for (auto i = 0; i < 5; i++) + { + FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; + auto hash = opentelemetry::sdk::common::GetHashForAttributeMap(attributes); + static_cast( + hash_map.GetOrSetDefault(attributes, aggregation_callback, hash)) + ->Aggregate(record_value); + } + EXPECT_EQ(hash_map.Size(), 10); // no new metric point added + // get the overflow metric point - auto agg = hash_map.GetOrSetDefault( + auto agg1 = hash_map.GetOrSetDefault( FilteredOrderedAttributeMap({{kAttributesLimitOverflowKey, kAttributesLimitOverflowValue}}), aggregation_callback, kOverflowAttributesHash); - EXPECT_NE(agg, nullptr); - auto sum_agg = static_cast(agg); - EXPECT_EQ(nostd::get(nostd::get(sum_agg->ToPoint()).value_), + EXPECT_NE(agg1, nullptr); + auto sum_agg1 = static_cast(agg1); + EXPECT_EQ(nostd::get(nostd::get(sum_agg1->ToPoint()).value_), record_value * 6); // 1 from previous 10, 5 from current 5. + // get remaining metric points + for (auto i = 0; i < 9; i++) + { + FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; + auto hash = opentelemetry::sdk::common::GetHashForAttributeMap(attributes); + auto agg2 = hash_map.GetOrSetDefault( + FilteredOrderedAttributeMap({{kAttributesLimitOverflowKey, kAttributesLimitOverflowValue}}), + aggregation_callback, hash); + EXPECT_NE(agg2, nullptr); + auto sum_agg2 = static_cast(agg2); + if (i < 5) + { + EXPECT_EQ(nostd::get(nostd::get(sum_agg2->ToPoint()).value_), + record_value * 2); // 1 from first recording, 1 from third recording + } + else + { + EXPECT_EQ(nostd::get(nostd::get(sum_agg2->ToPoint()).value_), + record_value); // 1 from first recording + } + } } class WritableMetricStorageCardinalityLimitTestFixture @@ -76,7 +130,7 @@ TEST_P(WritableMetricStorageCardinalityLimitTestFixture, LongCounterSumAggregati #endif nullptr, attributes_limit); - long record_value = 100; + int64_t record_value = 100; // add 9 unique metric points, and 6 more above limit. for (auto i = 0; i < 15; i++) { diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/circular_buffer_counter_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/circular_buffer_counter_test.cc index a8218d9e6bc..38b6000d3e5 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/circular_buffer_counter_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/circular_buffer_counter_test.cc @@ -1,11 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/data/circular_buffer.h" - #include +#include #include +#include "opentelemetry/sdk/metrics/data/circular_buffer.h" + using namespace opentelemetry::sdk::metrics; class AdaptingIntegerArrayTest : public testing::TestWithParam diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/common.cc b/deps/opentelemetry-cpp/sdk/test/metrics/common.cc index 87343f61867..8aff2f91fad 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/common.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/common.cc @@ -2,8 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 #include "common.h" +#include + +#include "opentelemetry/sdk/metrics/data/point_data.h" -using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::sdk::common; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/common.h b/deps/opentelemetry-cpp/sdk/test/metrics/common.h index b3b73e15d6c..ff2060e2858 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/common.h +++ b/deps/opentelemetry-cpp/sdk/test/metrics/common.h @@ -3,13 +3,16 @@ #pragma once -#include "opentelemetry/sdk/metrics/data/point_data.h" +#include +#include + +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/sdk/metrics/state/metric_collector.h" -#include - class MockMetricExporter : public opentelemetry::sdk::metrics::PushMetricExporter { public: diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_benchmark.cc index f85a4f47069..80ebb59069e 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_benchmark.cc @@ -1,18 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" -#include -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_test.cc index 6fd13c902cb..264e223cccc 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_test.cc @@ -1,17 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_test.cc index 4daceb685b3..8e0f3c1c1c5 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_test.cc @@ -1,17 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include #include "common.h" #include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX # include @@ -134,6 +148,66 @@ TEST(Histogram, DoubleCustomBuckets) ASSERT_EQ(std::vector({10, 20, 30, 40}), actual.boundaries_); ASSERT_EQ(std::vector({2, 2, 2, 2, 2}), actual.counts_); } + +TEST(Histogram, DoubleEmptyBuckets) +{ + MeterProvider mp; + auto m = mp.GetMeter("meter1", "version1", "schema1"); + std::string instrument_unit = "ms"; + std::string instrument_name = "historgram1"; + std::string instrument_desc = "histogram metrics"; + + std::unique_ptr exporter(new MockMetricExporter()); + std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; + mp.AddMetricReader(reader); + + std::shared_ptr config(new HistogramAggregationConfig()); + config->boundaries_ = {}; + std::unique_ptr view{ + new View("view1", "view1_description", instrument_unit, AggregationType::kHistogram, config)}; + std::unique_ptr instrument_selector{ + new InstrumentSelector(InstrumentType::kHistogram, 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->CreateDoubleHistogram(instrument_name, instrument_desc, instrument_unit); + + h->Record(-5, {}); + h->Record(10, {}); + h->Record(15, {}); + h->Record(20, {}); + h->Record(25, {}); + h->Record(30, {}); + h->Record(35, {}); + h->Record(40, {}); + h->Record(45, {}); + h->Record(50, {}); + + std::vector actuals; + reader->Collect([&](ResourceMetrics &rm) { + for (const ScopeMetrics &smd : rm.scope_metric_data_) + { + for (const MetricData &md : smd.metric_data_) + { + for (const PointDataAttributes &dp : md.point_data_attr_) + { + actuals.push_back(opentelemetry::nostd::get(dp.point_data)); + } + } + } + return true; + }); + + ASSERT_EQ(1, actuals.size()); + + const auto &actual = actuals.at(0); + ASSERT_EQ(270.0, opentelemetry::nostd::get(actual.sum_)); + ASSERT_EQ(9, actual.count_); + ASSERT_EQ(10.0, opentelemetry::nostd::get(actual.min_)); + ASSERT_EQ(50.0, opentelemetry::nostd::get(actual.max_)); + ASSERT_EQ(std::vector({}), actual.boundaries_); + ASSERT_EQ(std::vector({9}), actual.counts_); +} #endif TEST(Histogram, UInt64) @@ -249,4 +323,64 @@ TEST(Histogram, UInt64CustomBuckets) ASSERT_EQ(std::vector({10, 20, 30, 40}), actual.boundaries_); ASSERT_EQ(std::vector({2, 2, 2, 2, 2}), actual.counts_); } + +TEST(Histogram, UInt64EmptyBuckets) +{ + MeterProvider mp; + auto m = mp.GetMeter("meter1", "version1", "schema1"); + std::string instrument_name = "historgram1"; + std::string instrument_desc = "histogram metrics"; + std::string instrument_unit = "ms"; + + std::unique_ptr exporter(new MockMetricExporter()); + std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; + mp.AddMetricReader(reader); + + std::shared_ptr config(new HistogramAggregationConfig()); + config->boundaries_ = {}; + std::unique_ptr view{ + new View("view1", "view1_description", "ms", AggregationType::kHistogram, config)}; + std::unique_ptr instrument_selector{ + new InstrumentSelector(InstrumentType::kHistogram, 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->CreateUInt64Histogram(instrument_name, instrument_desc, instrument_unit); + + h->Record(5, {}); + h->Record(10, {}); + h->Record(15, {}); + h->Record(20, {}); + h->Record(25, {}); + h->Record(30, {}); + h->Record(35, {}); + h->Record(40, {}); + h->Record(45, {}); + h->Record(50, {}); + + std::vector actuals; + reader->Collect([&](ResourceMetrics &rm) { + for (const ScopeMetrics &smd : rm.scope_metric_data_) + { + for (const MetricData &md : smd.metric_data_) + { + for (const PointDataAttributes &dp : md.point_data_attr_) + { + actuals.push_back(opentelemetry::nostd::get(dp.point_data)); + } + } + } + return true; + }); + + ASSERT_EQ(1, actuals.size()); + + const auto &actual = actuals.at(0); + ASSERT_EQ(275, opentelemetry::nostd::get(actual.sum_)); + ASSERT_EQ(10, actual.count_); + ASSERT_EQ(5, opentelemetry::nostd::get(actual.min_)); + ASSERT_EQ(50, opentelemetry::nostd::get(actual.max_)); + ASSERT_EQ(std::vector({}), actual.boundaries_); + ASSERT_EQ(std::vector({10}), actual.counts_); +} #endif diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/instrument_metadata_validator_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/instrument_metadata_validator_test.cc index 172df1af3c3..1ecdc170250 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/instrument_metadata_validator_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/instrument_metadata_validator_test.cc @@ -1,8 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/instrument_metadata_validator.h" #include +#include +#include +#include + +#include "opentelemetry/sdk/metrics/instrument_metadata_validator.h" static std::string CreateVeryLargeString(size_t multiple) { @@ -19,9 +23,9 @@ TEST(InstrumentMetadataValidator, TestName) { opentelemetry::sdk::metrics::InstrumentMetaDataValidator validator; std::vector invalid_names = { - "", // empty string - "1sdf", // string starting with number - "\x31\x32\x33\xe2\x82\xac\x41\x41\x41\xe2\x82\xac\x42\x42\x42" // unicode characters + "", // empty string + "1sdf", // string starting with number + "\x31\x32\x33\xe2\x82\xac\x41\x41\x41\xe2\x82\xac\x42\x42\x42", // unicode characters "/\\sdsd", // string starting with special character "***sSSs", // string starting with special character "a\\broken\\path", // contains backward slash diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/measurements_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/metrics/measurements_benchmark.cc index 06ac75a65a1..15d96130b57 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/measurements_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/measurements_benchmark.cc @@ -1,15 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include -#include -#include using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/meter_provider_sdk_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/meter_provider_sdk_test.cc index 60ac7ab46f9..36cb28c228f 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/meter_provider_sdk_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/meter_provider_sdk_test.cc @@ -1,16 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include #include "common.h" -#include -#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/common/macros.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/sdk/metrics/view/instrument_selector.h" #include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" using namespace opentelemetry::sdk::metrics; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/meter_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/meter_test.cc index 084f50fc095..196be7b1059 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/meter_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/meter_test.cc @@ -1,16 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/metrics/async_instruments.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/meter_provider.h" +#include "opentelemetry/metrics/observer_result.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; @@ -18,7 +33,7 @@ using namespace opentelemetry::sdk::metrics; namespace { nostd::shared_ptr InitMeter(MetricReader **metricReaderPtr, - std::string meter_name = "meter_name") + const std::string &meter_name = "meter_name") { static std::shared_ptr provider(new MeterProvider()); std::unique_ptr metric_reader(new MockMetricReader()); @@ -28,7 +43,6 @@ nostd::shared_ptr InitMeter(MetricReader **metricReaderPtr, auto meter = provider->GetMeter(meter_name); return meter; } -} // namespace void asyc_generate_measurements(opentelemetry::metrics::ObserverResult observer, void * /* state */) { @@ -36,6 +50,7 @@ void asyc_generate_measurements(opentelemetry::metrics::ObserverResult observer, nostd::get>>(observer); observer_long->Observe(10); } +} // namespace TEST(MeterTest, BasicAsyncTests) { diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/metric_reader_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/metric_reader_test.cc index 061d505a1d2..330bca78185 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/metric_reader_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/metric_reader_test.cc @@ -1,12 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include #include "common.h" -#include +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/metric_reader.h" -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; @@ -25,5 +31,5 @@ TEST(MetricReaderTest, BasicTests) std::shared_ptr meter_context2(new MeterContext()); std::shared_ptr metric_producer{ new MetricCollector(meter_context2.get(), std::move(metric_reader2))}; - metric_producer->Collect([](ResourceMetrics & /* metric_data */) { return true; }); + metric_producer->Produce(); } diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/multi_metric_storage_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/multi_metric_storage_test.cc index 97c5a438ee4..e2449db9d58 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/multi_metric_storage_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/multi_metric_storage_test.cc @@ -1,18 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" -#include "opentelemetry/common/key_value_iterable_view.h" +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" +#include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" #endif // ENABLE_METRICS_EXEMPLAR_PREVIEW -#include "opentelemetry/sdk/metrics/instruments.h" - -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::metrics; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/observable_registry_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/observable_registry_test.cc index 6b6efb755a7..23957b8275c 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/observable_registry_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/observable_registry_test.cc @@ -1,11 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/observable_registry.h" -#include "opentelemetry/metrics/observer_result.h" - #include +#include "opentelemetry/sdk/metrics/state/observable_registry.h" + using namespace opentelemetry::sdk::metrics; #if 0 diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/observer_result_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/observer_result_test.cc index eea56738b90..73b7b86ec52 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/observer_result_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/observer_result_test.cc @@ -1,11 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/observer_result.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#include - using namespace opentelemetry::sdk::metrics; TEST(ObserverResult, BasicTests) { diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/periodic_exporting_metric_reader_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/periodic_exporting_metric_reader_test.cc index e115f79f750..4e92ecd6834 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/periodic_exporting_metric_reader_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/periodic_exporting_metric_reader_test.cc @@ -1,12 +1,25 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; @@ -14,8 +27,14 @@ using namespace opentelemetry::sdk::metrics; class MockPushMetricExporter : public PushMetricExporter { public: + MockPushMetricExporter(std::chrono::milliseconds wait) : wait_(wait) {} + opentelemetry::sdk::common::ExportResult Export(const ResourceMetrics &record) noexcept override { + if (wait_ > std::chrono::milliseconds::zero()) + { + std::this_thread::sleep_for(wait_); + } records_.push_back(record); return opentelemetry::sdk::common::ExportResult::kSuccess; } @@ -34,44 +53,61 @@ class MockPushMetricExporter : public PushMetricExporter private: std::vector records_; + std::chrono::milliseconds wait_; }; class MockMetricProducer : public MetricProducer { public: MockMetricProducer(std::chrono::microseconds sleep_ms = std::chrono::microseconds::zero()) - : sleep_ms_{sleep_ms}, data_sent_size_(0) + : sleep_ms_{sleep_ms} {} - bool Collect(nostd::function_ref callback) noexcept override + MetricProducer::Result Produce() noexcept override { std::this_thread::sleep_for(sleep_ms_); data_sent_size_++; ResourceMetrics data; - callback(data); - return true; + return {data, MetricProducer::Status::kSuccess}; } size_t GetDataCount() { return data_sent_size_; } private: std::chrono::microseconds sleep_ms_; - size_t data_sent_size_; + size_t data_sent_size_{0}; }; TEST(PeriodicExporingMetricReader, BasicTests) { - std::unique_ptr exporter(new MockPushMetricExporter()); + std::unique_ptr exporter( + new MockPushMetricExporter(std::chrono::milliseconds{0})); PeriodicExportingMetricReaderOptions options; options.export_timeout_millis = std::chrono::milliseconds(200); options.export_interval_millis = std::chrono::milliseconds(500); auto exporter_ptr = exporter.get(); - PeriodicExportingMetricReader reader(std::move(exporter), options); + std::shared_ptr reader = + std::make_shared(std::move(exporter), options); MockMetricProducer producer; - reader.SetMetricProducer(&producer); + reader->SetMetricProducer(&producer); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - EXPECT_NO_THROW(reader.ForceFlush()); - reader.Shutdown(); + reader->ForceFlush(); + reader->Shutdown(); EXPECT_EQ(static_cast(exporter_ptr)->GetDataCount(), static_cast(&producer)->GetDataCount()); } + +TEST(PeriodicExporingMetricReader, Timeout) +{ + std::unique_ptr exporter( + new MockPushMetricExporter(std::chrono::milliseconds{2000})); + PeriodicExportingMetricReaderOptions options; + options.export_timeout_millis = std::chrono::milliseconds(200); + options.export_interval_millis = std::chrono::milliseconds(500); + std::shared_ptr reader = + std::make_shared(std::move(exporter), options); + MockMetricProducer producer; + reader->SetMetricProducer(&producer); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + reader->Shutdown(); +} diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_benchmark.cc index 728b3542a12..b2e44b15e58 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_benchmark.cc @@ -1,19 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" -#include -#include -#include - using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_test.cc index 33a111974e3..73caebbe7eb 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_test.cc @@ -1,17 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/macros.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/sync_instruments.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" -#include "opentelemetry/sdk/metrics/meter.h" -#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sync_instruments_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sync_instruments_test.cc index 723d29f20e9..fb59e1d0333 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/sync_instruments_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sync_instruments_test.cc @@ -1,15 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/sync_instruments.h" +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" -#include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" #include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" - -#include -#include -#include +#include "opentelemetry/sdk/metrics/sync_instruments.h" using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_counter_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_counter_test.cc index 2593b697199..c67b9d499a0 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_counter_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_counter_test.cc @@ -1,25 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" -#include +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/context/context.h" -#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #if ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif -#include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" -#include "opentelemetry/sdk/metrics/view/attributes_processor.h" - -#include -#include - using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; using M = std::map; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_histogram_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_histogram_test.cc index 71a16b85c6b..34145743d91 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_histogram_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_histogram_test.cc @@ -1,24 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif -#include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" -#include "opentelemetry/sdk/metrics/view/attributes_processor.h" - -#include -#include -#include - using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; using M = std::map; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc index 216574a5876..4732e5b9f23 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc @@ -1,22 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" - -#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" -#endif - +#include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#include -#include -#include +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +#endif using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; @@ -71,7 +82,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) auto collection_ts = std::chrono::system_clock::now(); size_t count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -105,7 +116,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { if (temporality == AggregationTemporality::kCumulative) { EXPECT_EQ(data.start_ts, sdk_start_ts); @@ -147,7 +158,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -224,7 +235,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) auto collection_ts = std::chrono::system_clock::now(); size_t count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -259,7 +270,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { if (temporality == AggregationTemporality::kCumulative) { EXPECT_EQ(data.start_ts, sdk_start_ts); @@ -301,7 +312,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/view_registry_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/view_registry_test.cc index fb188e71240..0135227e16c 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/view_registry_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/view_registry_test.cc @@ -1,12 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/view/view_registry.h" +#include +#include +#include +#include + +#include "opentelemetry/common/macros.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/metrics/instruments.h" -#include "opentelemetry/sdk/metrics/view/predicate.h" - -#include +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" +#include "opentelemetry/sdk/metrics/view/view_registry.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX # include diff --git a/deps/opentelemetry-cpp/sdk/test/resource/resource_test.cc b/deps/opentelemetry-cpp/sdk/test/resource/resource_test.cc index e6b56cae431..c15087e9b75 100644 --- a/deps/opentelemetry-cpp/sdk/test/resource/resource_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/resource/resource_test.cc @@ -1,17 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/common/attribute_utils.h" -#include "opentelemetry/sdk/resource/resource_detector.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" -#include "opentelemetry/sdk/version/version.h" - +#include +#include #include #include #include +#include +#include -#include +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/resource/resource_detector.h" +#include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "opentelemetry/sdk/version/version.h" #if defined(_MSC_VER) # include "opentelemetry/sdk/common/env_variables.h" @@ -25,7 +29,8 @@ namespace nostd = opentelemetry::nostd; class TestResource : public Resource { public: - TestResource(ResourceAttributes attributes = ResourceAttributes(), std::string schema_url = {}) + TestResource(const ResourceAttributes &attributes = ResourceAttributes(), + const std::string &schema_url = {}) : Resource(attributes, schema_url) {} }; @@ -122,10 +127,10 @@ TEST(ResourceTest, create_with_emptyatrributes) TEST(ResourceTest, create_with_schemaurl) { - const std::string schema_url = "https://opentelemetry.io/schemas/1.2.0"; - ResourceAttributes attributes = {}; - auto resource = Resource::Create(attributes, schema_url); - auto received_schema_url = resource.GetSchemaURL(); + const std::string schema_url = "https://opentelemetry.io/schemas/1.2.0"; + ResourceAttributes attributes = {}; + auto resource = Resource::Create(attributes, schema_url); + const auto &received_schema_url = resource.GetSchemaURL(); EXPECT_EQ(received_schema_url, schema_url); } diff --git a/deps/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc index 1c32bd5a8f8..5680e22c75f 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc @@ -2,8 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" using opentelemetry::sdk::trace::AlwaysOffSampler; using opentelemetry::sdk::trace::Decision; diff --git a/deps/opentelemetry-cpp/sdk/test/trace/always_on_sampler_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/always_on_sampler_test.cc index c483f9b8be9..04b7e60a2b9 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/always_on_sampler_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/always_on_sampler_test.cc @@ -1,12 +1,24 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" - -#include -#include +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" using namespace opentelemetry::sdk::trace; using namespace opentelemetry::nostd; diff --git a/deps/opentelemetry-cpp/sdk/test/trace/batch_span_processor_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/batch_span_processor_test.cc index 411b4dacfe8..293747350a8 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/batch_span_processor_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/batch_span_processor_test.cc @@ -1,21 +1,28 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/batch_span_processor.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/trace/batch_span_processor.h" #include "opentelemetry/sdk/trace/batch_span_processor_options.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/sdk/trace/tracer.h" - -#include - -#include -#include -#include -#include -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -32,10 +39,10 @@ class MockSpanExporter final : public sdk::trace::SpanExporter std::shared_ptr> is_export_completed = std::shared_ptr>(new std::atomic(false)), const std::chrono::milliseconds export_delay = std::chrono::milliseconds(0)) noexcept - : spans_received_(spans_received), - shut_down_counter_(shut_down_counter), - is_shutdown_(is_shutdown), - is_export_completed_(is_export_completed), + : spans_received_(std::move(spans_received)), + shut_down_counter_(std::move(shut_down_counter)), + is_shutdown_(std::move(is_shutdown)), + is_export_completed_(std::move(is_export_completed)), export_delay_(export_delay) {} @@ -96,7 +103,7 @@ class BatchSpanProcessorTestPeer : public testing::Test { public: std::unique_ptr>> GetTestSpans( - std::shared_ptr processor, + const std::shared_ptr &processor, const int num_spans) { std::unique_ptr>> test_spans( diff --git a/deps/opentelemetry-cpp/sdk/test/trace/parent_sampler_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/parent_sampler_test.cc index 7d2ef7f1075..a6ed8ff7f8c 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/parent_sampler_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/parent_sampler_test.cc @@ -2,11 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/samplers/parent.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" using opentelemetry::sdk::trace::AlwaysOffSampler; using opentelemetry::sdk::trace::AlwaysOnSampler; diff --git a/deps/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc index ec188b84a19..529143b53e2 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc @@ -1,20 +1,34 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/exporters/memory/in_memory_span_exporter.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/samplers/parent.h" #include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h" #include "opentelemetry/sdk/trace/simple_processor.h" -#include "opentelemetry/sdk/trace/span_data.h" #include "opentelemetry/sdk/trace/tracer.h" - -#include - -#include +#include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable_view.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer.h" using namespace opentelemetry::sdk::trace; using opentelemetry::exporter::memory::InMemorySpanExporter; diff --git a/deps/opentelemetry-cpp/sdk/test/trace/simple_processor_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/simple_processor_test.cc index 7653bb2cfc2..92fdf71d582 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/simple_processor_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/simple_processor_test.cc @@ -1,13 +1,23 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/simple_processor.h" +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/memory/in_memory_span_data.h" #include "opentelemetry/exporters/memory/in_memory_span_exporter.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/span_data.h" - -#include +#include "opentelemetry/trace/span_context.h" using namespace opentelemetry::sdk::trace; using namespace opentelemetry::sdk::common; diff --git a/deps/opentelemetry-cpp/sdk/test/trace/span_data_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/span_data_test.cc index 98d00843dd7..054af653303 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/span_data_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/span_data_test.cc @@ -1,18 +1,32 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/span_data.h" +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/variant.h" -#include "opentelemetry/trace/span.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/span_data.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" - -#include +#include "opentelemetry/trace/trace_state.h" using opentelemetry::sdk::trace::SpanData; namespace trace_api = opentelemetry::trace; namespace common = opentelemetry::common; -namespace nostd = opentelemetry::nostd; TEST(SpanData, DefaultValues) { @@ -70,7 +84,7 @@ TEST(SpanData, Set) ASSERT_EQ(data.GetDescription(), "description"); ASSERT_EQ(data.GetStartTime().time_since_epoch(), now.time_since_epoch()); ASSERT_EQ(data.GetDuration(), std::chrono::nanoseconds(1000000)); - ASSERT_EQ(nostd::get(data.GetAttributes().at("attr1")), 314159); + ASSERT_EQ(opentelemetry::nostd::get(data.GetAttributes().at("attr1")), 314159); ASSERT_EQ(data.GetEvents().at(0).GetName(), "event1"); ASSERT_EQ(data.GetEvents().at(0).GetTimestamp(), now); } @@ -89,15 +103,17 @@ TEST(SpanData, EventAttributes) for (int i = 0; i < kNumAttributes; i++) { - EXPECT_EQ(nostd::get(data.GetEvents().at(0).GetAttributes().at(keys[i])), values[i]); + EXPECT_EQ( + opentelemetry::nostd::get(data.GetEvents().at(0).GetAttributes().at(keys[i])), + values[i]); } } TEST(SpanData, Resources) { SpanData data; - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - auto input_attr = resource.GetAttributes(); + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + const auto &input_attr = resource.GetAttributes(); data.SetResource(resource); auto output_attr = data.GetResource().GetAttributes(); EXPECT_EQ(input_attr, output_attr); @@ -130,6 +146,7 @@ TEST(SpanData, Links) EXPECT_EQ(data.GetLinks().at(0).GetSpanContext(), span_context); for (int i = 0; i < kNumAttributes; i++) { - EXPECT_EQ(nostd::get(data.GetLinks().at(0).GetAttributes().at(keys[i])), values[i]); + EXPECT_EQ(opentelemetry::nostd::get(data.GetLinks().at(0).GetAttributes().at(keys[i])), + values[i]); } } diff --git a/deps/opentelemetry-cpp/sdk/test/trace/trace_id_ratio_sampler_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/trace_id_ratio_sampler_test.cc index 1b0088f134e..ac83a8dc6d8 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/trace_id_ratio_sampler_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/trace_id_ratio_sampler_test.cc @@ -1,14 +1,26 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" #include "src/common/random.h" -#include -#include -#include - using opentelemetry::sdk::common::Random; using opentelemetry::sdk::trace::Decision; using opentelemetry::sdk::trace::TraceIdRatioBasedSampler; diff --git a/deps/opentelemetry-cpp/sdk/test/trace/tracer_provider_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/tracer_provider_test.cc index 9715a7e0b84..fa3afa26908 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/tracer_provider_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/tracer_provider_test.cc @@ -1,20 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/tracer_provider.h" +#include +#include +#include +#include + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/random_id_generator.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" -#include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/tracer.h" - -#include +#include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" using namespace opentelemetry::sdk::trace; using namespace opentelemetry::sdk::resource; -#include - TEST(TracerProvider, GetTracer) { std::unique_ptr processor(new SimpleSpanProcessor(nullptr)); diff --git a/deps/opentelemetry-cpp/sdk/test/trace/tracer_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/tracer_test.cc index 99bab95b0f6..2c4de8e83c4 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/tracer_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/tracer_test.cc @@ -1,17 +1,58 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/tracer.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/macros.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/exporters/memory/in_memory_span_data.h" #include "opentelemetry/exporters/memory/in_memory_span_exporter.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/random_id_generator.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/samplers/parent.h" #include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/span_data.h" +#include "opentelemetry/sdk/trace/tracer.h" +#include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/trace/context.h" - -#include +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/span_startoptions.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" +#include "opentelemetry/trace/tracer.h" using namespace opentelemetry::sdk::trace; using namespace opentelemetry::sdk::resource; @@ -20,7 +61,6 @@ using opentelemetry::common::SystemTimestamp; namespace nostd = opentelemetry::nostd; namespace common = opentelemetry::common; namespace trace_api = opentelemetry::trace; -using opentelemetry::common::KeyValueIterableView; using opentelemetry::exporter::memory::InMemorySpanData; using opentelemetry::exporter::memory::InMemorySpanExporter; using opentelemetry::trace::SpanContext; diff --git a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/pprofextended.proto b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/pprofextended.proto index bd300835546..b5b5b88fcef 100644 --- a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/pprofextended.proto +++ b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/pprofextended.proto @@ -59,6 +59,8 @@ package opentelemetry.proto.profiles.v1experimental; import "opentelemetry/proto/common/v1/common.proto"; option csharp_namespace = "OpenTelemetry.Proto.Profiles.V1Experimental"; +option java_multiple_files = true; +option java_package = "io.opentelemetry.proto.profiles.v1experimental"; option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1experimental"; // Represents a complete profile, including sample types, samples, @@ -203,7 +205,7 @@ enum AggregationTemporality { 11. A request is received, the system measures 1 request. 12. The 1 second collection cycle ends. A metric is exported for the number of requests received over the interval of time t_1 to - t_0+1 with a value of 1. + t_1+1 with a value of 1. Note: Even though, when reporting changes since last report time, using CUMULATIVE is valid, it is not recommended. */ diff --git a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/profiles.proto b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/profiles.proto index bbc2b2931da..84b0108f86a 100644 --- a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/profiles.proto +++ b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/profiles.proto @@ -55,7 +55,7 @@ option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1experimental"; // ┌──────────────────┐ // │ Profile │ // └──────────────────┘ -// │ 1-n +// │ n-1 // │ 1-n ┌───────────────────────────────────────┐ // ▼ │ ▽ // ┌──────────────────┐ 1-n ┌──────────────┐ ┌──────────┐ diff --git a/deps/opentelemetry-cpp/third_party_release b/deps/opentelemetry-cpp/third_party_release new file mode 100644 index 00000000000..7362473f609 --- /dev/null +++ b/deps/opentelemetry-cpp/third_party_release @@ -0,0 +1,25 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 +# +# MAINTAINER +# +# This file is used for the CMake build. +# +# When changing (add, upgrade, remove) dependencies +# please update: +# - the Bazel build, see file +# /bazel/repository.bzl +# - git submodule, see command +# git submodule status +# + +gRPC=v1.49.2 +abseil=20240116.1 +benchmark=v1.8.3 +googletest=1.14.0 +ms-gsl=v3.1.0-67-g6f45293 +nlohmann-json=v3.11.3 +opentelemetry-proto=v1.3.2 +opentracing-cpp=v1.6.0 +prometheus-cpp=v1.2.4 +vcpkg=2024.02.14 diff --git a/tools/dep_updaters/update-opentelemetry-cpp.sh b/tools/dep_updaters/update-opentelemetry-cpp.sh index 966132c7cd9..fdfc2b6df2f 100755 --- a/tools/dep_updaters/update-opentelemetry-cpp.sh +++ b/tools/dep_updaters/update-opentelemetry-cpp.sh @@ -24,7 +24,7 @@ console.log(tag_name.replace('v', '')); EOF )" -CURRENT_VERSION=$(grep "#define OPENTELEMETRY_VERSION" ./deps/opentelemetry-cpp/api/include/version.h | awk -F'"' '{print $2}') +CURRENT_VERSION=$(grep "#define OPENTELEMETRY_VERSION" ./deps/opentelemetry-cpp/api/include/opentelemetry/version.h | awk -F'"' '{print $2}') # This function exit with 0 if new version and current version are the same compare_dependency_version "opentelemetry-cpp" "$NEW_VERSION" "$CURRENT_VERSION" @@ -58,7 +58,13 @@ cd opentelemetry-cpp echo "Removing everything, except src/ and LICENSE" for dir in *; do - if [ "$dir" = "api" ] || [ "$dir" = "exporters" ] || [ "$dir" = "ext" ] || [ "$dir" = "sdk" ] || [ "$dir" = "third_party" ] || [ "$dir" = "LICENSE" ]; then + if [ "$dir" = "api" ] || \ + [ "$dir" = "exporters" ] || \ + [ "$dir" = "ext" ] || \ + [ "$dir" = "sdk" ] || \ + [ "$dir" = "third_party" ] || \ + [ "$dir" = "LICENSE" ] || \ + [ "$dir" = "third_party_release" ]; then continue fi rm -rf "$dir" @@ -79,7 +85,7 @@ curl -sL -o "$PROTOC_ZIP" "https://github.com/protocolbuffers/protobuf/releases/ unzip -o "$PROTOC_ZIP" -d ./protoc/ echo "Getting opentelemetry-proto files" -OTEL_PROTO_VERSION="1.3.1" +OTEL_PROTO_VERSION=$(grep "opentelemetry-proto" "opentelemetry-cpp/third_party_release" | awk -F"=v" '{print $2}') OTEL_PROTO_TARBALL=v$OTEL_PROTO_VERSION.tar.gz curl -sL -o "$OTEL_PROTO_TARBALL" "https://github.com/open-telemetry/opentelemetry-proto/archive/refs/tags/$OTEL_PROTO_TARBALL" @@ -96,7 +102,7 @@ cp out/Release/grpc_cpp_plugin "$WORKSPACE/protoc/bin/" cd "$WORKSPACE" echo "Building protobuf files" -cd opentelemetry-proto-$OTEL_PROTO_VERSION +cd "opentelemetry-proto-$OTEL_PROTO_VERSION" mkdir -p "$WORKSPACE/opentelemetry-cpp/third_party/opentelemetry-proto/gen/cpp" "$WORKSPACE/protoc/bin/protoc" \ --cpp_out="$WORKSPACE/opentelemetry-cpp/third_party/opentelemetry-proto/gen/cpp" \ From a50340b5c2cef1c92469ef0867d13ce787330197 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 12 Sep 2024 17:30:16 +0200 Subject: [PATCH 05/19] deps: add support for exporting Summary via OTLP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodesource/nsolid/pull/180 Reviewed-By: Rafael Gonzaga Reviewed-by: Trevor Norris PR-URL: https://github.com/nodesource/nsolid/pull/221 Reviewed-By: Juan José Arboleda --- .../exporters/otlp/otlp_metric_utils.h | 3 + .../exporters/otlp/src/otlp_metric_utils.cc | 63 +++++++++++++++++++ .../metrics/aggregation/default_aggregation.h | 2 + .../sdk/metrics/data/metric_data.h | 2 +- .../sdk/metrics/data/point_data.h | 14 +++++ .../opentelemetry/sdk/metrics/instruments.h | 4 +- 6 files changed, 86 insertions(+), 2 deletions(-) diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h index 4f92b8e665a..832a76be02b 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h @@ -58,6 +58,9 @@ class OtlpMetricUtils static void ConvertGaugeMetric(const opentelemetry::sdk::metrics::MetricData &metric_data, proto::metrics::v1::Gauge *const gauge) noexcept; + static void ConvertSummaryMetric(const opentelemetry::sdk::metrics::MetricData &metric_data, + proto::metrics::v1::Summary *const summary) noexcept; + static void PopulateInstrumentInfoMetrics( const opentelemetry::sdk::metrics::MetricData &metric_data, proto::metrics::v1::Metric *metric) noexcept; diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_metric_utils.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_metric_utils.cc index da162d117ea..103135ad1d8 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_metric_utils.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_metric_utils.cc @@ -69,6 +69,11 @@ metric_sdk::AggregationType OtlpMetricUtils::GetAggregationType( { return metric_sdk::AggregationType::kLastValue; } + else if (nostd::holds_alternative( + point_data_with_attributes.point_data)) + { + return metric_sdk::AggregationType::kSummary; + } return metric_sdk::AggregationType::kDrop; } @@ -208,6 +213,56 @@ void OtlpMetricUtils::ConvertGaugeMetric(const opentelemetry::sdk::metrics::Metr } } +void OtlpMetricUtils::ConvertSummaryMetric(const metric_sdk::MetricData &metric_data, + proto::metrics::v1::Summary *const summary) noexcept +{ + auto start_ts = metric_data.start_ts.time_since_epoch().count(); + auto ts = metric_data.end_ts.time_since_epoch().count(); + for (auto &point_data_with_attributes : metric_data.point_data_attr_) + { + proto::metrics::v1::SummaryDataPoint *proto_summary_point_data = summary->add_data_points(); + proto_summary_point_data->set_start_time_unix_nano(start_ts); + proto_summary_point_data->set_time_unix_nano(ts); + auto summary_data = nostd::get(point_data_with_attributes.point_data); + + // sum + if ((nostd::holds_alternative(summary_data.sum_))) + { + // Use static_cast to avoid C4244 in MSVC + proto_summary_point_data->set_sum( + static_cast(nostd::get(summary_data.sum_))); + } + else + { + proto_summary_point_data->set_sum(nostd::get(summary_data.sum_)); + } + // count + proto_summary_point_data->set_count(summary_data.count_); + // quantile values + for (auto &kv : summary_data.quantile_values_) + { + proto::metrics::v1::SummaryDataPoint::ValueAtQuantile *quantile = + proto_summary_point_data->add_quantile_values(); + quantile->set_quantile(kv.first); + if ((nostd::holds_alternative(kv.second))) + { + // Use static_cast to avoid C4244 in MSVC + quantile->set_value(static_cast(nostd::get(kv.second))); + } + else + { + quantile->set_value(nostd::get(kv.second)); + } + } + // set attributes + for (auto &kv_attr : point_data_with_attributes.attributes) + { + OtlpPopulateAttributeUtils::PopulateAttribute(proto_summary_point_data->add_attributes(), + kv_attr.first, kv_attr.second); + } + } +} + void OtlpMetricUtils::PopulateInstrumentInfoMetrics( const opentelemetry::sdk::metrics::MetricData &metric_data, proto::metrics::v1::Metric *metric) noexcept @@ -230,6 +285,10 @@ void OtlpMetricUtils::PopulateInstrumentInfoMetrics( ConvertGaugeMetric(metric_data, metric->mutable_gauge()); break; } + case metric_sdk::AggregationType::kSummary: { + ConvertSummaryMetric(metric_data, metric->mutable_summary()); + break; + } default: break; } @@ -301,6 +360,8 @@ sdk::metrics::AggregationTemporality OtlpMetricUtils::DeltaTemporalitySelector( case sdk::metrics::InstrumentType::kUpDownCounter: case sdk::metrics::InstrumentType::kObservableUpDownCounter: return sdk::metrics::AggregationTemporality::kCumulative; + case sdk::metrics::InstrumentType::kSummary: + return sdk::metrics::AggregationTemporality::kUnspecified; } return sdk::metrics::AggregationTemporality::kUnspecified; } @@ -324,6 +385,8 @@ sdk::metrics::AggregationTemporality OtlpMetricUtils::LowMemoryTemporalitySelect case sdk::metrics::InstrumentType::kUpDownCounter: case sdk::metrics::InstrumentType::kObservableUpDownCounter: return sdk::metrics::AggregationTemporality::kCumulative; + case sdk::metrics::InstrumentType::kSummary: + return sdk::metrics::AggregationTemporality::kUnspecified; } return sdk::metrics::AggregationTemporality::kUnspecified; } diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h index 4f3346707fe..1d14c0760e5 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h @@ -182,6 +182,8 @@ class DefaultAggregation return AggregationType::kHistogram; case InstrumentType::kObservableGauge: return AggregationType::kLastValue; + case InstrumentType::kSummary: + return AggregationType::kSummary; default: return AggregationType::kDrop; } diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/data/metric_data.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/data/metric_data.h index ad1084f5819..dfe4d94eff0 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/data/metric_data.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/data/metric_data.h @@ -19,7 +19,7 @@ namespace metrics using PointAttributes = opentelemetry::sdk::common::OrderedAttributeMap; using PointType = opentelemetry::nostd:: - variant; + variant; struct PointDataAttributes { diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/data/point_data.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/data/point_data.h index 32853316a54..4cd19d3ea2a 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/data/point_data.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/data/point_data.h @@ -74,6 +74,20 @@ class DropPointData DropPointData &operator=(DropPointData &&) = default; }; +class SummaryPointData +{ +public: +// TODO: remove ctors and initializers when GCC<5 stops shipping on Ubuntu + SummaryPointData(SummaryPointData &&) = default; + SummaryPointData(const SummaryPointData &) = default; + SummaryPointData &operator=(SummaryPointData &&) = default; + SummaryPointData() = default; + + uint64_t count_ = {}; + ValueType sum_ = {}; + std::unordered_map quantile_values_ = {}; +}; + } // namespace metrics } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/instruments.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/instruments.h index d7c6870945f..eb9fc30a5a4 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/instruments.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/instruments.h @@ -21,7 +21,8 @@ enum class InstrumentType kUpDownCounter, kObservableCounter, kObservableGauge, - kObservableUpDownCounter + kObservableUpDownCounter, + kSummary }; enum class InstrumentClass @@ -44,6 +45,7 @@ enum class AggregationType kHistogram, kLastValue, kSum, + kSummary, kDefault }; From 7deace99684bbef23dc0ce225b5ce4315cd30cbf Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 21 Nov 2024 15:02:20 +0100 Subject: [PATCH 06/19] test: get opentelemetry version from process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodesource/nsolid/pull/221 Reviewed-By: Juan José Arboleda --- test/agents/test-otlp-grpc-metrics.mjs | 2 +- test/agents/test-otlp-metrics.mjs | 2 +- test/common/nsolid-grpc-agent/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/agents/test-otlp-grpc-metrics.mjs b/test/agents/test-otlp-grpc-metrics.mjs index 7e1503c455d..a04aeb4323f 100644 --- a/test/agents/test-otlp-grpc-metrics.mjs +++ b/test/agents/test-otlp-grpc-metrics.mjs @@ -448,7 +448,7 @@ if (process.argv[2] === 'child') { validateArray(resource.attributes, 'attributes'); const expectedAttributes = { - 'telemetry.sdk.version': '1.16.0', + 'telemetry.sdk.version': process.versions.opentelemetry, 'telemetry.sdk.language': 'cpp', 'telemetry.sdk.name': 'opentelemetry', 'service.instance.id': nsolidId, diff --git a/test/agents/test-otlp-metrics.mjs b/test/agents/test-otlp-metrics.mjs index 4f0ee3b9265..cdb132ce765 100644 --- a/test/agents/test-otlp-metrics.mjs +++ b/test/agents/test-otlp-metrics.mjs @@ -447,7 +447,7 @@ if (process.argv[2] === 'child') { validateArray(resource.attributes, 'attributes'); const expectedAttributes = { - 'telemetry.sdk.version': '1.16.0', + 'telemetry.sdk.version': process.versions.opentelemetry, 'telemetry.sdk.language': 'cpp', 'telemetry.sdk.name': 'opentelemetry', 'service.instance.id': nsolidId, diff --git a/test/common/nsolid-grpc-agent/index.js b/test/common/nsolid-grpc-agent/index.js index 85685bda701..7273649c784 100644 --- a/test/common/nsolid-grpc-agent/index.js +++ b/test/common/nsolid-grpc-agent/index.js @@ -44,7 +44,7 @@ function checkResource(resource, agentId, config, metrics) { validateArray(resource.attributes, 'attributes'); const expectedAttributes = { - 'telemetry.sdk.version': '1.16.0', + 'telemetry.sdk.version': process.versions.opentelemetry, 'telemetry.sdk.language': 'cpp', 'telemetry.sdk.name': 'opentelemetry', 'service.instance.id': agentId, From 741412ca2b6a17b860286c0a2010cc1a5078de1b Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Mon, 9 Dec 2024 15:46:20 +0100 Subject: [PATCH 07/19] deps: avoid using unset values in cpu profiler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `lineNumber`, `columnNumber` and `url` node fields can be actually undefined. Make sure we avoid integer overflows and potential crashes. As an example, if `lineNumber` or `columnNumber` are undefined, they were taking the `4294967295` which obviously doesn't make any sense. PR-URL: https://github.com/nodesource/nsolid/pull/233 Reviewed-By: Juan José Arboleda --- deps/v8/src/profiler/profile-generator.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/deps/v8/src/profiler/profile-generator.cc b/deps/v8/src/profiler/profile-generator.cc index 901599adf70..8d448a96248 100644 --- a/deps/v8/src/profiler/profile-generator.cc +++ b/deps/v8/src/profiler/profile-generator.cc @@ -804,14 +804,24 @@ void CpuProfileJSONSerializer::SerializeCallFrame( const v8::CpuProfileNode* node) { writer_->AddString("\"functionName\":"); writer_->EscapeAndAddString(node->GetFunctionNameStr()); - writer_->AddString(",\"lineNumber\":"); - writer_->AddNumber(node->GetLineNumber() - 1); - writer_->AddString(",\"columnNumber\":"); - writer_->AddNumber(node->GetColumnNumber() - 1); + if (node->GetLineNumber()) { + writer_->AddString(",\"lineNumber\":"); + writer_->AddNumber(node->GetLineNumber() - 1); + } + + if (node->GetColumnNumber()) { + writer_->AddString(",\"columnNumber\":"); + writer_->AddNumber(node->GetColumnNumber() - 1); + } + writer_->AddString(",\"scriptId\":"); writer_->AddNumber(node->GetScriptId()); - writer_->AddString(",\"url\":"); - writer_->EscapeAndAddString(node->GetScriptResourceNameStr()); + + const char* url = node->GetScriptResourceNameStr(); + if (url) { + writer_->AddString(",\"url\":"); + writer_->EscapeAndAddString(url); + } } void CpuProfileJSONSerializer::SerializeChildren(const v8::CpuProfileNode* node, From ad3d41d29bfdebf7ec496d574f64279ff5020112 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Tue, 17 Dec 2024 09:52:30 +0100 Subject: [PATCH 08/19] src: add scriptId to stack@blocked_loop event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodesource/nsolid/pull/238 Reviewed-By: Juan José Arboleda --- agents/grpc/proto/blocked_loop.proto | 1 + agents/grpc/src/grpc_agent.cc | 1 + agents/grpc/src/proto/blocked_loop.pb.cc | 76 ++++++++++++++++-------- agents/grpc/src/proto/blocked_loop.pb.h | 31 ++++++++++ src/nsolid/nsolid_api.cc | 2 + test/agents/test-grpc-blocked-loop.mjs | 1 + test/agents/test-zmq-blocked-loop.mjs | 1 + 7 files changed, 88 insertions(+), 25 deletions(-) diff --git a/agents/grpc/proto/blocked_loop.proto b/agents/grpc/proto/blocked_loop.proto index f5070872eb5..33e4cc0ca94 100644 --- a/agents/grpc/proto/blocked_loop.proto +++ b/agents/grpc/proto/blocked_loop.proto @@ -15,6 +15,7 @@ message Stack { string function_name = 3; int32 line_number = 4; int32 column = 5; + int32 script_id = 6; } message BlockedLoopBody { diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index a47b03f0fb6..df64471bb16 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -170,6 +170,7 @@ void PopulateBlockedLoopEvent(grpcagent::BlockedLoopEvent* blocked_loop_event, proto_stack->set_line_number(stack["line_number"].get()); proto_stack->set_column(stack["column"].get()); + proto_stack->set_script_id(stack["scriptId"].get()); } } diff --git a/agents/grpc/src/proto/blocked_loop.pb.cc b/agents/grpc/src/proto/blocked_loop.pb.cc index e70f7e7fdc4..55bd86be140 100644 --- a/agents/grpc/src/proto/blocked_loop.pb.cc +++ b/agents/grpc/src/proto/blocked_loop.pb.cc @@ -28,6 +28,7 @@ PROTOBUF_CONSTEXPR Stack::Stack( , /*decltype(_impl_.is_eval_)*/false , /*decltype(_impl_.line_number_)*/0 , /*decltype(_impl_.column_)*/0 + , /*decltype(_impl_.script_id_)*/0 , /*decltype(_impl_._cached_size_)*/{}} {} struct StackDefaultTypeInternal { PROTOBUF_CONSTEXPR StackDefaultTypeInternal() @@ -116,6 +117,7 @@ const uint32_t TableStruct_blocked_5floop_2eproto::offsets[] PROTOBUF_SECTION_VA PROTOBUF_FIELD_OFFSET(::grpcagent::Stack, _impl_.function_name_), PROTOBUF_FIELD_OFFSET(::grpcagent::Stack, _impl_.line_number_), PROTOBUF_FIELD_OFFSET(::grpcagent::Stack, _impl_.column_), + PROTOBUF_FIELD_OFFSET(::grpcagent::Stack, _impl_.script_id_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::grpcagent::BlockedLoopBody, _internal_metadata_), ~0u, // no _extensions_ @@ -156,10 +158,10 @@ const uint32_t TableStruct_blocked_5floop_2eproto::offsets[] PROTOBUF_SECTION_VA }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::grpcagent::Stack)}, - { 11, -1, -1, sizeof(::grpcagent::BlockedLoopBody)}, - { 22, -1, -1, sizeof(::grpcagent::BlockedLoopEvent)}, - { 30, -1, -1, sizeof(::grpcagent::UnblockedLoopBody)}, - { 40, -1, -1, sizeof(::grpcagent::UnblockedLoopEvent)}, + { 12, -1, -1, sizeof(::grpcagent::BlockedLoopBody)}, + { 23, -1, -1, sizeof(::grpcagent::BlockedLoopEvent)}, + { 31, -1, -1, sizeof(::grpcagent::UnblockedLoopBody)}, + { 41, -1, -1, sizeof(::grpcagent::UnblockedLoopEvent)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -172,28 +174,28 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_blocked_5floop_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\022blocked_loop.proto\022\tgrpcagent\032\014common." - "proto\"i\n\005Stack\022\017\n\007is_eval\030\001 \001(\010\022\023\n\013scrip" + "proto\"|\n\005Stack\022\017\n\007is_eval\030\001 \001(\010\022\023\n\013scrip" "t_name\030\002 \001(\t\022\025\n\rfunction_name\030\003 \001(\t\022\023\n\013l" - "ine_number\030\004 \001(\005\022\016\n\006column\030\005 \001(\005\"\202\001\n\017Blo" - "ckedLoopBody\022\021\n\tthread_id\030\001 \001(\003\022\023\n\013block" - "ed_for\030\002 \001(\005\022\017\n\007loop_id\030\003 \001(\005\022\025\n\rcallbac" - "k_cntr\030\004 \001(\005\022\037\n\005stack\030\005 \003(\0132\020.grpcagent." - "Stack\"g\n\020BlockedLoopEvent\022)\n\006common\030\001 \001(" - "\0132\031.grpcagent.CommonResponse\022(\n\004body\030\002 \001" - "(\0132\032.grpcagent.BlockedLoopBody\"c\n\021Unbloc" - "kedLoopBody\022\021\n\tthread_id\030\001 \001(\003\022\023\n\013blocke" - "d_for\030\002 \001(\005\022\017\n\007loop_id\030\003 \001(\005\022\025\n\rcallback" - "_cntr\030\004 \001(\005\"k\n\022UnblockedLoopEvent\022)\n\006com" - "mon\030\001 \001(\0132\031.grpcagent.CommonResponse\022*\n\004" - "body\030\002 \001(\0132\034.grpcagent.UnblockedLoopBody" - "b\006proto3" + "ine_number\030\004 \001(\005\022\016\n\006column\030\005 \001(\005\022\021\n\tscri" + "pt_id\030\006 \001(\005\"\202\001\n\017BlockedLoopBody\022\021\n\tthrea" + "d_id\030\001 \001(\003\022\023\n\013blocked_for\030\002 \001(\005\022\017\n\007loop_" + "id\030\003 \001(\005\022\025\n\rcallback_cntr\030\004 \001(\005\022\037\n\005stack" + "\030\005 \003(\0132\020.grpcagent.Stack\"g\n\020BlockedLoopE" + "vent\022)\n\006common\030\001 \001(\0132\031.grpcagent.CommonR" + "esponse\022(\n\004body\030\002 \001(\0132\032.grpcagent.Blocke" + "dLoopBody\"c\n\021UnblockedLoopBody\022\021\n\tthread" + "_id\030\001 \001(\003\022\023\n\013blocked_for\030\002 \001(\005\022\017\n\007loop_i" + "d\030\003 \001(\005\022\025\n\rcallback_cntr\030\004 \001(\005\"k\n\022Unbloc" + "kedLoopEvent\022)\n\006common\030\001 \001(\0132\031.grpcagent" + ".CommonResponse\022*\n\004body\030\002 \001(\0132\034.grpcagen" + "t.UnblockedLoopBodyb\006proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_blocked_5floop_2eproto_deps[1] = { &::descriptor_table_common_2eproto, }; static ::_pbi::once_flag descriptor_table_blocked_5floop_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_blocked_5floop_2eproto = { - false, false, 608, descriptor_table_protodef_blocked_5floop_2eproto, + false, false, 627, descriptor_table_protodef_blocked_5floop_2eproto, "blocked_loop.proto", &descriptor_table_blocked_5floop_2eproto_once, descriptor_table_blocked_5floop_2eproto_deps, 1, 5, schemas, file_default_instances, TableStruct_blocked_5floop_2eproto::offsets, @@ -229,6 +231,7 @@ Stack::Stack(const Stack& from) , decltype(_impl_.is_eval_){} , decltype(_impl_.line_number_){} , decltype(_impl_.column_){} + , decltype(_impl_.script_id_){} , /*decltype(_impl_._cached_size_)*/{}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); @@ -249,8 +252,8 @@ Stack::Stack(const Stack& from) _this->GetArenaForAllocation()); } ::memcpy(&_impl_.is_eval_, &from._impl_.is_eval_, - static_cast(reinterpret_cast(&_impl_.column_) - - reinterpret_cast(&_impl_.is_eval_)) + sizeof(_impl_.column_)); + static_cast(reinterpret_cast(&_impl_.script_id_) - + reinterpret_cast(&_impl_.is_eval_)) + sizeof(_impl_.script_id_)); // @@protoc_insertion_point(copy_constructor:grpcagent.Stack) } @@ -264,6 +267,7 @@ inline void Stack::SharedCtor( , decltype(_impl_.is_eval_){false} , decltype(_impl_.line_number_){0} , decltype(_impl_.column_){0} + , decltype(_impl_.script_id_){0} , /*decltype(_impl_._cached_size_)*/{} }; _impl_.script_name_.InitDefault(); @@ -304,8 +308,8 @@ void Stack::Clear() { _impl_.script_name_.ClearToEmpty(); _impl_.function_name_.ClearToEmpty(); ::memset(&_impl_.is_eval_, 0, static_cast( - reinterpret_cast(&_impl_.column_) - - reinterpret_cast(&_impl_.is_eval_)) + sizeof(_impl_.column_)); + reinterpret_cast(&_impl_.script_id_) - + reinterpret_cast(&_impl_.is_eval_)) + sizeof(_impl_.script_id_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -359,6 +363,14 @@ const char* Stack::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { } else goto handle_unusual; continue; + // int32 script_id = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 48)) { + _impl_.script_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -426,6 +438,12 @@ uint8_t* Stack::_InternalSerialize( target = ::_pbi::WireFormatLite::WriteInt32ToArray(5, this->_internal_column(), target); } + // int32 script_id = 6; + if (this->_internal_script_id() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(6, this->_internal_script_id(), target); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -471,6 +489,11 @@ size_t Stack::ByteSizeLong() const { total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_column()); } + // int32 script_id = 6; + if (this->_internal_script_id() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_script_id()); + } + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } @@ -504,6 +527,9 @@ void Stack::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF if (from._internal_column() != 0) { _this->_internal_set_column(from._internal_column()); } + if (from._internal_script_id() != 0) { + _this->_internal_set_script_id(from._internal_script_id()); + } _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } @@ -532,8 +558,8 @@ void Stack::InternalSwap(Stack* other) { &other->_impl_.function_name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Stack, _impl_.column_) - + sizeof(Stack::_impl_.column_) + PROTOBUF_FIELD_OFFSET(Stack, _impl_.script_id_) + + sizeof(Stack::_impl_.script_id_) - PROTOBUF_FIELD_OFFSET(Stack, _impl_.is_eval_)>( reinterpret_cast(&_impl_.is_eval_), reinterpret_cast(&other->_impl_.is_eval_)); diff --git a/agents/grpc/src/proto/blocked_loop.pb.h b/agents/grpc/src/proto/blocked_loop.pb.h index 8e7c079d54b..ce73cd9a0c7 100644 --- a/agents/grpc/src/proto/blocked_loop.pb.h +++ b/agents/grpc/src/proto/blocked_loop.pb.h @@ -199,6 +199,7 @@ class Stack final : kIsEvalFieldNumber = 1, kLineNumberFieldNumber = 4, kColumnFieldNumber = 5, + kScriptIdFieldNumber = 6, }; // string script_name = 2; void clear_script_name(); @@ -255,6 +256,15 @@ class Stack final : void _internal_set_column(int32_t value); public: + // int32 script_id = 6; + void clear_script_id(); + int32_t script_id() const; + void set_script_id(int32_t value); + private: + int32_t _internal_script_id() const; + void _internal_set_script_id(int32_t value); + public: + // @@protoc_insertion_point(class_scope:grpcagent.Stack) private: class _Internal; @@ -268,6 +278,7 @@ class Stack final : bool is_eval_; int32_t line_number_; int32_t column_; + int32_t script_id_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; }; union { Impl_ _impl_; }; @@ -1180,6 +1191,26 @@ inline void Stack::set_column(int32_t value) { // @@protoc_insertion_point(field_set:grpcagent.Stack.column) } +// int32 script_id = 6; +inline void Stack::clear_script_id() { + _impl_.script_id_ = 0; +} +inline int32_t Stack::_internal_script_id() const { + return _impl_.script_id_; +} +inline int32_t Stack::script_id() const { + // @@protoc_insertion_point(field_get:grpcagent.Stack.script_id) + return _internal_script_id(); +} +inline void Stack::_internal_set_script_id(int32_t value) { + + _impl_.script_id_ = value; +} +inline void Stack::set_script_id(int32_t value) { + _internal_set_script_id(value); + // @@protoc_insertion_point(field_set:grpcagent.Stack.script_id) +} + // ------------------------------------------------------------------- // BlockedLoopBody diff --git a/src/nsolid/nsolid_api.cc b/src/nsolid/nsolid_api.cc index 657534027ad..0dbfadfef80 100644 --- a/src/nsolid/nsolid_api.cc +++ b/src/nsolid/nsolid_api.cc @@ -388,6 +388,8 @@ std::string EnvInst::GetOnBlockedBody() { frame += std::to_string(stack_frame->GetLineNumber()); frame += ",\"column\":"; frame += std::to_string(stack_frame->GetColumn()); + frame += ",\"scriptId\":"; + frame += std::to_string(stack_frame->GetScriptId()); frame += "},"; body_string += frame; diff --git a/test/agents/test-grpc-blocked-loop.mjs b/test/agents/test-grpc-blocked-loop.mjs index 52533e91b92..721658d942d 100644 --- a/test/agents/test-grpc-blocked-loop.mjs +++ b/test/agents/test-grpc-blocked-loop.mjs @@ -92,6 +92,7 @@ function checkBlockedLoopData(blocked, metadata, agentId, threadId) { validateInteger(frame.lineNumber, 'lineNumber'); validateInteger(frame.column, 'column'); + validateInteger(frame.scriptId, 'scriptId'); } assert.strictEqual(blocked.body.threadId, `${threadId}`); diff --git a/test/agents/test-zmq-blocked-loop.mjs b/test/agents/test-zmq-blocked-loop.mjs index fd0a1ab8886..ea919d91277 100644 --- a/test/agents/test-zmq-blocked-loop.mjs +++ b/test/agents/test-zmq-blocked-loop.mjs @@ -88,6 +88,7 @@ function checkBlockedLoopData(blocked, agentId, threadId) { validateInteger(frame.line_number, 'line_number'); validateInteger(frame.column, 'column'); + validateInteger(frame.scriptId, 'scriptId'); } assert.strictEqual(blocked.body.threadId, threadId); From a02d20b9c11e73c94d1d716cc995e2f8e146af7e Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Fri, 6 Dec 2024 17:18:50 +0100 Subject: [PATCH 09/19] src,agents: add support for source code collection The runtime now stores the `scriptId` and `url` or `path` of all the loaded cjs and esm modules. A new grpc command has been added to retrieve the source code for any `scriptId`-`url|path` pair by reading the source code from file. In case the specific `scriptId`-`url|path` pair wasn't stored, it returns an error. In the rare case where a ESM is not loaded from a file URL, the code would be stored on loading time. PR-URL: https://github.com/nodesource/nsolid/pull/240 Reviewed-By: Rafael Gonzaga --- agents/grpc/proto/command.proto | 2 + agents/grpc/proto/nsolid_service.proto | 2 + agents/grpc/proto/source_code.proto | 19 + agents/grpc/src/grpc_agent.cc | 52 ++ agents/grpc/src/grpc_agent.h | 2 + agents/grpc/src/grpc_client.cc | 19 + agents/grpc/src/grpc_client.h | 10 + agents/grpc/src/grpc_errors.h | 3 +- agents/grpc/src/proto/command.pb.cc | 97 ++- agents/grpc/src/proto/command.pb.h | 89 ++ .../grpc/src/proto/nsolid_service.grpc.pb.cc | 44 +- .../grpc/src/proto/nsolid_service.grpc.pb.h | 183 +++- agents/grpc/src/proto/nsolid_service.pb.cc | 53 +- agents/grpc/src/proto/nsolid_service.pb.h | 1 + agents/grpc/src/proto/source_code.grpc.pb.cc | 25 + agents/grpc/src/proto/source_code.grpc.pb.h | 33 + agents/grpc/src/proto/source_code.pb.cc | 759 +++++++++++++++++ agents/grpc/src/proto/source_code.pb.h | 791 ++++++++++++++++++ node.gyp | 4 + src/module_wrap.cc | 4 + src/node_contextify.cc | 5 + src/nsolid/nsolid_api.cc | 64 ++ src/nsolid/nsolid_api.h | 17 + test/agents/test-grpc-source-code.mjs | 340 ++++++++ test/common/nsolid-grpc-agent/client.js | 25 + test/common/nsolid-grpc-agent/index.js | 31 + test/common/nsolid-grpc-agent/server.mjs | 17 + test/fixtures/nsolid-source-code/common.js | 8 + test/fixtures/nsolid-source-code/data.mjs | 18 + test/fixtures/nsolid-source-code/esm.mjs | 7 + test/fixtures/nsolid-source-code/index.mjs | 7 + 31 files changed, 2678 insertions(+), 53 deletions(-) create mode 100644 agents/grpc/proto/source_code.proto create mode 100644 agents/grpc/src/proto/source_code.grpc.pb.cc create mode 100644 agents/grpc/src/proto/source_code.grpc.pb.h create mode 100644 agents/grpc/src/proto/source_code.pb.cc create mode 100644 agents/grpc/src/proto/source_code.pb.h create mode 100644 test/agents/test-grpc-source-code.mjs create mode 100644 test/fixtures/nsolid-source-code/common.js create mode 100644 test/fixtures/nsolid-source-code/data.mjs create mode 100644 test/fixtures/nsolid-source-code/esm.mjs create mode 100644 test/fixtures/nsolid-source-code/index.mjs diff --git a/agents/grpc/proto/command.proto b/agents/grpc/proto/command.proto index 7f4a51c5c1e..88438994780 100644 --- a/agents/grpc/proto/command.proto +++ b/agents/grpc/proto/command.proto @@ -7,6 +7,7 @@ syntax = "proto3"; import "profile.proto"; import "reconfigure.proto"; +import "source_code.proto"; package grpcagent; @@ -14,6 +15,7 @@ message CommandArgs { oneof args { ReconfigureBody reconfigure = 1; ProfileArgs profile = 2; + SourceCodeArgs source_code = 3; } } diff --git a/agents/grpc/proto/nsolid_service.proto b/agents/grpc/proto/nsolid_service.proto index 8a35162d38d..5a850fe953a 100644 --- a/agents/grpc/proto/nsolid_service.proto +++ b/agents/grpc/proto/nsolid_service.proto @@ -8,6 +8,7 @@ import "info.proto"; import "metrics.proto"; import "packages.proto"; import "reconfigure.proto"; +import "source_code.proto"; import "startup_times.proto"; package grpcagent; @@ -22,6 +23,7 @@ service NSolidService { rpc ExportBlockedLoop (BlockedLoopEvent) returns (EventResponse) {} rpc ExportUnblockedLoop (UnblockedLoopEvent) returns (EventResponse) {} rpc ExportReconfigure (ReconfigureEvent) returns (EventResponse) {} + rpc ExportSourceCode (SourceCodeEvent) returns (EventResponse) {} rpc ExportStartupTimes (StartupTimesEvent) returns (EventResponse) {} } diff --git a/agents/grpc/proto/source_code.proto b/agents/grpc/proto/source_code.proto new file mode 100644 index 00000000000..d0b294aa92f --- /dev/null +++ b/agents/grpc/proto/source_code.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +import "common.proto"; + +package grpcagent; + +message SourceCodeArgs { + int64 thread_id = 1; + int32 script_id = 2; + string path = 3; +} + +message SourceCodeEvent { + CommonResponse common = 1; + int64 thread_id = 2; + string path = 3; + string code = 4; + bool is_esm = 5; +} diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index df64471bb16..bcc083dc032 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -1439,6 +1439,8 @@ void GrpcAgent::handle_command_request(CommandRequestStor&& req) { start_heap_sampling(request); } else if (cmd == "snapshot") { start_heap_snapshot(request); + } else if (cmd == "source_code") { + send_source_code_event(request); } else if (cmd == "startup_times") { send_startup_times_event(request.requestid().c_str()); } else { @@ -1724,6 +1726,56 @@ void GrpcAgent::send_reconfigure_event(const char* req_id) { }); } +void GrpcAgent::send_source_code_event(const grpcagent::CommandRequest& req) { + const grpcagent::SourceCodeArgs& args = req.args().source_code(); + uint64_t thread_id = args.thread_id(); + int script_id = args.script_id(); + const std::string path = args.path(); + + ArenaOptions arena_options; + arena_options.initial_block_size = 1024; + arena_options.max_block_size = 65536; + std::unique_ptr arena{new Arena{arena_options}}; + + auto source_code_event = + Arena::Create(arena.get()); + PopulateCommon(source_code_event->mutable_common(), + "source_code", + req.requestid().c_str()); + + source_code_event->set_thread_id(thread_id); + source_code_event->set_path(path); + + + auto envinst_sp = EnvInst::GetInst(thread_id); + if (envinst_sp == nullptr) { + Debug("Error getting EnvInst for thread: %ld\n", thread_id); + PopulateError(source_code_event->mutable_common(), + ErrorType::EThreadGoneError); + } else { + int r = envinst_sp->GetSourceCode(script_id, + path, + source_code_event->mutable_code()); + if (r != 0) { + Debug("Error reading file from: %s. Error: %d.\n", path.c_str(), r); + PopulateError(source_code_event->mutable_common(), + ErrorType::ESourceCodeFileError); + } + } + + auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + + GrpcClient::DelegateAsyncExport( + nsolid_service_stub_.get(), std::move(context), std::move(arena), + std::move(*source_code_event), + [](::grpc::Status, + std::unique_ptr&&, + const grpcagent::SourceCodeEvent& info_event, + grpcagent::EventResponse*) { + return true; + }); +} + void GrpcAgent::send_startup_times_event(const char* req_id) { ArenaOptions arena_options; arena_options.initial_block_size = 1024; diff --git a/agents/grpc/src/grpc_agent.h b/agents/grpc/src/grpc_agent.h index 07a59fc2699..13192cca0f5 100644 --- a/agents/grpc/src/grpc_agent.h +++ b/agents/grpc/src/grpc_agent.h @@ -267,6 +267,8 @@ class GrpcAgent: public std::enable_shared_from_this, void send_reconfigure_event(const char* req_id); + void send_source_code_event(const grpcagent::CommandRequest& req); + void send_startup_times_event(const char* req_id); void send_unblocked_loop_event(BlockedLoopStor&& stor); diff --git a/agents/grpc/src/grpc_client.cc b/agents/grpc/src/grpc_client.cc index 36a22ee5930..064581e3aac 100644 --- a/agents/grpc/src/grpc_client.cc +++ b/agents/grpc/src/grpc_client.cc @@ -273,6 +273,25 @@ int GrpcClient::DelegateAsyncExport( } +int GrpcClient::DelegateAsyncExport( + NSolidService::StubInterface* stub, + std::unique_ptr&& context, + std::unique_ptr&& arena, + grpcagent::SourceCodeEvent&& event, + std::function &&, + const grpcagent::SourceCodeEvent&, + grpcagent::EventResponse*)>&& result_callback) noexcept { + return InternalDelegateAsyncExport( + stub, + &NSolidService::StubInterface::async_interface::ExportSourceCode, + std::move(context), + std::move(arena), + std::move(event), + std::move(result_callback)); +} + + int GrpcClient::DelegateAsyncExport( NSolidService::StubInterface* stub, std::unique_ptr&& context, diff --git a/agents/grpc/src/grpc_client.h b/agents/grpc/src/grpc_client.h index 2a2d54b3086..8c710d223fb 100644 --- a/agents/grpc/src/grpc_client.h +++ b/agents/grpc/src/grpc_client.h @@ -113,6 +113,16 @@ class GrpcClient { const grpcagent::ReconfigureEvent&, grpcagent::EventResponse*)>&& result_callback) noexcept; + static int DelegateAsyncExport( + grpcagent::NSolidService::StubInterface* stub, + std::unique_ptr<::grpc::ClientContext>&& context, + std::unique_ptr&& arena, + grpcagent::SourceCodeEvent&& event, + std::function &&, + const grpcagent::SourceCodeEvent&, + grpcagent::EventResponse*)>&& result_callback) noexcept; + static int DelegateAsyncExport( grpcagent::NSolidService::StubInterface* stub, std::unique_ptr<::grpc::ClientContext>&& context, diff --git a/agents/grpc/src/grpc_errors.h b/agents/grpc/src/grpc_errors.h index e8163057a49..84db558eab1 100644 --- a/agents/grpc/src/grpc_errors.h +++ b/agents/grpc/src/grpc_errors.h @@ -8,7 +8,8 @@ X(EProfSnapshotError, 500, "Profile/Snapshot creation failure", 1003) \ X(ESnapshotDisabled, 500, "Heap Snapshots disabled", 1004) \ X(ENoMemory, 500, "Internal Runtime Error", 1005) \ - X(ENotAvailable, 404, "Resource not available", 1006) + X(ENotAvailable, 404, "Resource not available", 1006) \ + X(ESourceCodeFileError, 500, "Internal Runtime Error", 1007) namespace node { namespace nsolid { diff --git a/agents/grpc/src/proto/command.pb.cc b/agents/grpc/src/proto/command.pb.cc index 85a3cbe804b..f50cf0cd5ae 100644 --- a/agents/grpc/src/proto/command.pb.cc +++ b/agents/grpc/src/proto/command.pb.cc @@ -79,6 +79,7 @@ const uint32_t TableStruct_command_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( ~0u, // no _inlined_string_donated_ ::_pbi::kInvalidFieldOffsetTag, ::_pbi::kInvalidFieldOffsetTag, + ::_pbi::kInvalidFieldOffsetTag, PROTOBUF_FIELD_OFFSET(::grpcagent::CommandArgs, _impl_.args_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::grpcagent::CommandRequest, _internal_metadata_), @@ -101,8 +102,8 @@ const uint32_t TableStruct_command_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::grpcagent::CommandArgs)}, - { 9, -1, -1, sizeof(::grpcagent::CommandRequest)}, - { 19, -1, -1, sizeof(::grpcagent::CommandResponse)}, + { 10, -1, -1, sizeof(::grpcagent::CommandRequest)}, + { 20, -1, -1, sizeof(::grpcagent::CommandResponse)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -113,24 +114,27 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_command_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\rcommand.proto\022\tgrpcagent\032\rprofile.prot" - "o\032\021reconfigure.proto\"s\n\013CommandArgs\0221\n\013r" - "econfigure\030\001 \001(\0132\032.grpcagent.Reconfigure" - "BodyH\000\022)\n\007profile\030\002 \001(\0132\026.grpcagent.Prof" - "ileArgsH\000B\006\n\004args\"f\n\016CommandRequest\022\021\n\tr" - "equestId\030\001 \001(\t\022\n\n\002id\030\002 \001(\t\022\017\n\007command\030\003 " - "\001(\t\022$\n\004args\030\004 \001(\0132\026.grpcagent.CommandArg" - "s\"0\n\017CommandResponse\022\014\n\004code\030\001 \001(\r\022\017\n\007me" - "ssage\030\002 \001(\tb\006proto3" + "o\032\021reconfigure.proto\032\021source_code.proto\"" + "\245\001\n\013CommandArgs\0221\n\013reconfigure\030\001 \001(\0132\032.g" + "rpcagent.ReconfigureBodyH\000\022)\n\007profile\030\002 " + "\001(\0132\026.grpcagent.ProfileArgsH\000\0220\n\013source_" + "code\030\003 \001(\0132\031.grpcagent.SourceCodeArgsH\000B" + "\006\n\004args\"f\n\016CommandRequest\022\021\n\trequestId\030\001" + " \001(\t\022\n\n\002id\030\002 \001(\t\022\017\n\007command\030\003 \001(\t\022$\n\004arg" + "s\030\004 \001(\0132\026.grpcagent.CommandArgs\"0\n\017Comma" + "ndResponse\022\014\n\004code\030\001 \001(\r\022\017\n\007message\030\002 \001(" + "\tb\006proto3" ; -static const ::_pbi::DescriptorTable* const descriptor_table_command_2eproto_deps[2] = { +static const ::_pbi::DescriptorTable* const descriptor_table_command_2eproto_deps[3] = { &::descriptor_table_profile_2eproto, &::descriptor_table_reconfigure_2eproto, + &::descriptor_table_source_5fcode_2eproto, }; static ::_pbi::once_flag descriptor_table_command_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_command_2eproto = { - false, false, 339, descriptor_table_protodef_command_2eproto, + false, false, 409, descriptor_table_protodef_command_2eproto, "command.proto", - &descriptor_table_command_2eproto_once, descriptor_table_command_2eproto_deps, 2, 3, + &descriptor_table_command_2eproto_once, descriptor_table_command_2eproto_deps, 3, 3, schemas, file_default_instances, TableStruct_command_2eproto::offsets, file_level_metadata_command_2eproto, file_level_enum_descriptors_command_2eproto, file_level_service_descriptors_command_2eproto, @@ -149,6 +153,7 @@ class CommandArgs::_Internal { public: static const ::grpcagent::ReconfigureBody& reconfigure(const CommandArgs* msg); static const ::grpcagent::ProfileArgs& profile(const CommandArgs* msg); + static const ::grpcagent::SourceCodeArgs& source_code(const CommandArgs* msg); }; const ::grpcagent::ReconfigureBody& @@ -159,6 +164,10 @@ const ::grpcagent::ProfileArgs& CommandArgs::_Internal::profile(const CommandArgs* msg) { return *msg->_impl_.args_.profile_; } +const ::grpcagent::SourceCodeArgs& +CommandArgs::_Internal::source_code(const CommandArgs* msg) { + return *msg->_impl_.args_.source_code_; +} void CommandArgs::set_allocated_reconfigure(::grpcagent::ReconfigureBody* reconfigure) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); clear_args(); @@ -207,6 +216,30 @@ void CommandArgs::clear_profile() { clear_has_args(); } } +void CommandArgs::set_allocated_source_code(::grpcagent::SourceCodeArgs* source_code) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + clear_args(); + if (source_code) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_code)); + if (message_arena != submessage_arena) { + source_code = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, source_code, submessage_arena); + } + set_has_source_code(); + _impl_.args_.source_code_ = source_code; + } + // @@protoc_insertion_point(field_set_allocated:grpcagent.CommandArgs.source_code) +} +void CommandArgs::clear_source_code() { + if (_internal_has_source_code()) { + if (GetArenaForAllocation() == nullptr) { + delete _impl_.args_.source_code_; + } + clear_has_args(); + } +} CommandArgs::CommandArgs(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { @@ -234,6 +267,11 @@ CommandArgs::CommandArgs(const CommandArgs& from) from._internal_profile()); break; } + case kSourceCode: { + _this->_internal_mutable_source_code()->::grpcagent::SourceCodeArgs::MergeFrom( + from._internal_source_code()); + break; + } case ARGS_NOT_SET: { break; } @@ -288,6 +326,12 @@ void CommandArgs::clear_args() { } break; } + case kSourceCode: { + if (GetArenaForAllocation() == nullptr) { + delete _impl_.args_.source_code_; + } + break; + } case ARGS_NOT_SET: { break; } @@ -328,6 +372,14 @@ const char* CommandArgs::_InternalParse(const char* ptr, ::_pbi::ParseContext* c } else goto handle_unusual; continue; + // .grpcagent.SourceCodeArgs source_code = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_source_code(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -371,6 +423,13 @@ uint8_t* CommandArgs::_InternalSerialize( _Internal::profile(this).GetCachedSize(), target, stream); } + // .grpcagent.SourceCodeArgs source_code = 3; + if (_internal_has_source_code()) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::source_code(this), + _Internal::source_code(this).GetCachedSize(), target, stream); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -402,6 +461,13 @@ size_t CommandArgs::ByteSizeLong() const { *_impl_.args_.profile_); break; } + // .grpcagent.SourceCodeArgs source_code = 3; + case kSourceCode: { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.args_.source_code_); + break; + } case ARGS_NOT_SET: { break; } @@ -435,6 +501,11 @@ void CommandArgs::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR from._internal_profile()); break; } + case kSourceCode: { + _this->_internal_mutable_source_code()->::grpcagent::SourceCodeArgs::MergeFrom( + from._internal_source_code()); + break; + } case ARGS_NOT_SET: { break; } diff --git a/agents/grpc/src/proto/command.pb.h b/agents/grpc/src/proto/command.pb.h index f1d6c879ba9..20bb6d9487f 100644 --- a/agents/grpc/src/proto/command.pb.h +++ b/agents/grpc/src/proto/command.pb.h @@ -32,6 +32,7 @@ #include #include "profile.pb.h" #include "reconfigure.pb.h" +#include "source_code.pb.h" // @@protoc_insertion_point(includes) #include #define PROTOBUF_INTERNAL_EXPORT_command_2eproto @@ -112,6 +113,7 @@ class CommandArgs final : enum ArgsCase { kReconfigure = 1, kProfile = 2, + kSourceCode = 3, ARGS_NOT_SET = 0, }; @@ -195,6 +197,7 @@ class CommandArgs final : enum : int { kReconfigureFieldNumber = 1, kProfileFieldNumber = 2, + kSourceCodeFieldNumber = 3, }; // .grpcagent.ReconfigureBody reconfigure = 1; bool has_reconfigure() const; @@ -232,6 +235,24 @@ class CommandArgs final : ::grpcagent::ProfileArgs* profile); ::grpcagent::ProfileArgs* unsafe_arena_release_profile(); + // .grpcagent.SourceCodeArgs source_code = 3; + bool has_source_code() const; + private: + bool _internal_has_source_code() const; + public: + void clear_source_code(); + const ::grpcagent::SourceCodeArgs& source_code() const; + PROTOBUF_NODISCARD ::grpcagent::SourceCodeArgs* release_source_code(); + ::grpcagent::SourceCodeArgs* mutable_source_code(); + void set_allocated_source_code(::grpcagent::SourceCodeArgs* source_code); + private: + const ::grpcagent::SourceCodeArgs& _internal_source_code() const; + ::grpcagent::SourceCodeArgs* _internal_mutable_source_code(); + public: + void unsafe_arena_set_allocated_source_code( + ::grpcagent::SourceCodeArgs* source_code); + ::grpcagent::SourceCodeArgs* unsafe_arena_release_source_code(); + void clear_args(); ArgsCase args_case() const; // @@protoc_insertion_point(class_scope:grpcagent.CommandArgs) @@ -239,6 +260,7 @@ class CommandArgs final : class _Internal; void set_has_reconfigure(); void set_has_profile(); + void set_has_source_code(); inline bool has_args() const; inline void clear_has_args(); @@ -252,6 +274,7 @@ class CommandArgs final : ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; ::grpcagent::ReconfigureBody* reconfigure_; ::grpcagent::ProfileArgs* profile_; + ::grpcagent::SourceCodeArgs* source_code_; } args_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; uint32_t _oneof_case_[1]; @@ -772,6 +795,72 @@ inline ::grpcagent::ProfileArgs* CommandArgs::mutable_profile() { return _msg; } +// .grpcagent.SourceCodeArgs source_code = 3; +inline bool CommandArgs::_internal_has_source_code() const { + return args_case() == kSourceCode; +} +inline bool CommandArgs::has_source_code() const { + return _internal_has_source_code(); +} +inline void CommandArgs::set_has_source_code() { + _impl_._oneof_case_[0] = kSourceCode; +} +inline ::grpcagent::SourceCodeArgs* CommandArgs::release_source_code() { + // @@protoc_insertion_point(field_release:grpcagent.CommandArgs.source_code) + if (_internal_has_source_code()) { + clear_has_args(); + ::grpcagent::SourceCodeArgs* temp = _impl_.args_.source_code_; + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + _impl_.args_.source_code_ = nullptr; + return temp; + } else { + return nullptr; + } +} +inline const ::grpcagent::SourceCodeArgs& CommandArgs::_internal_source_code() const { + return _internal_has_source_code() + ? *_impl_.args_.source_code_ + : reinterpret_cast< ::grpcagent::SourceCodeArgs&>(::grpcagent::_SourceCodeArgs_default_instance_); +} +inline const ::grpcagent::SourceCodeArgs& CommandArgs::source_code() const { + // @@protoc_insertion_point(field_get:grpcagent.CommandArgs.source_code) + return _internal_source_code(); +} +inline ::grpcagent::SourceCodeArgs* CommandArgs::unsafe_arena_release_source_code() { + // @@protoc_insertion_point(field_unsafe_arena_release:grpcagent.CommandArgs.source_code) + if (_internal_has_source_code()) { + clear_has_args(); + ::grpcagent::SourceCodeArgs* temp = _impl_.args_.source_code_; + _impl_.args_.source_code_ = nullptr; + return temp; + } else { + return nullptr; + } +} +inline void CommandArgs::unsafe_arena_set_allocated_source_code(::grpcagent::SourceCodeArgs* source_code) { + clear_args(); + if (source_code) { + set_has_source_code(); + _impl_.args_.source_code_ = source_code; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:grpcagent.CommandArgs.source_code) +} +inline ::grpcagent::SourceCodeArgs* CommandArgs::_internal_mutable_source_code() { + if (!_internal_has_source_code()) { + clear_args(); + set_has_source_code(); + _impl_.args_.source_code_ = CreateMaybeMessage< ::grpcagent::SourceCodeArgs >(GetArenaForAllocation()); + } + return _impl_.args_.source_code_; +} +inline ::grpcagent::SourceCodeArgs* CommandArgs::mutable_source_code() { + ::grpcagent::SourceCodeArgs* _msg = _internal_mutable_source_code(); + // @@protoc_insertion_point(field_mutable:grpcagent.CommandArgs.source_code) + return _msg; +} + inline bool CommandArgs::has_args() const { return args_case() != ARGS_NOT_SET; } diff --git a/agents/grpc/src/proto/nsolid_service.grpc.pb.cc b/agents/grpc/src/proto/nsolid_service.grpc.pb.cc index a3056a65c33..ede9326f8ee 100644 --- a/agents/grpc/src/proto/nsolid_service.grpc.pb.cc +++ b/agents/grpc/src/proto/nsolid_service.grpc.pb.cc @@ -31,6 +31,7 @@ static const char* NSolidService_method_names[] = { "/grpcagent.NSolidService/ExportBlockedLoop", "/grpcagent.NSolidService/ExportUnblockedLoop", "/grpcagent.NSolidService/ExportReconfigure", + "/grpcagent.NSolidService/ExportSourceCode", "/grpcagent.NSolidService/ExportStartupTimes", }; @@ -50,7 +51,8 @@ NSolidService::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& chan , rpcmethod_ExportBlockedLoop_(NSolidService_method_names[6], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) , rpcmethod_ExportUnblockedLoop_(NSolidService_method_names[7], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) , rpcmethod_ExportReconfigure_(NSolidService_method_names[8], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportStartupTimes_(NSolidService_method_names[9], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportSourceCode_(NSolidService_method_names[9], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportStartupTimes_(NSolidService_method_names[10], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) {} ::grpc::ClientReaderWriter< ::grpcagent::CommandResponse, ::grpcagent::CommandRequest>* NSolidService::Stub::CommandRaw(::grpc::ClientContext* context) { @@ -246,6 +248,29 @@ ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* NSolidService::S return result; } +::grpc::Status NSolidService::Stub::ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpcagent::EventResponse* response) { + return ::grpc::internal::BlockingUnaryCall< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_ExportSourceCode_, context, request, response); +} + +void NSolidService::Stub::async::ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, std::function f) { + ::grpc::internal::CallbackUnaryCall< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_ExportSourceCode_, context, request, response, std::move(f)); +} + +void NSolidService::Stub::async::ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) { + ::grpc::internal::ClientCallbackUnaryFactory::Create< ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_ExportSourceCode_, context, request, response, reactor); +} + +::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* NSolidService::Stub::PrepareAsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::grpcagent::EventResponse, ::grpcagent::SourceCodeEvent, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_ExportSourceCode_, context, request); +} + +::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* NSolidService::Stub::AsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + auto* result = + this->PrepareAsyncExportSourceCodeRaw(context, request, cq); + result->StartCall(); + return result; +} + ::grpc::Status NSolidService::Stub::ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpcagent::EventResponse* response) { return ::grpc::internal::BlockingUnaryCall< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_ExportStartupTimes_, context, request, response); } @@ -363,6 +388,16 @@ NSolidService::Service::Service() { AddMethod(new ::grpc::internal::RpcServiceMethod( NSolidService_method_names[9], ::grpc::internal::RpcMethod::NORMAL_RPC, + new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( + [](NSolidService::Service* service, + ::grpc::ServerContext* ctx, + const ::grpcagent::SourceCodeEvent* req, + ::grpcagent::EventResponse* resp) { + return service->ExportSourceCode(ctx, req, resp); + }, this))); + AddMethod(new ::grpc::internal::RpcServiceMethod( + NSolidService_method_names[10], + ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, ::grpc::ServerContext* ctx, @@ -437,6 +472,13 @@ ::grpc::Status NSolidService::Service::ExportReconfigure(::grpc::ServerContext* return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } +::grpc::Status NSolidService::Service::ExportSourceCode(::grpc::ServerContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response) { + (void) context; + (void) request; + (void) response; + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); +} + ::grpc::Status NSolidService::Service::ExportStartupTimes(::grpc::ServerContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response) { (void) context; (void) request; diff --git a/agents/grpc/src/proto/nsolid_service.grpc.pb.h b/agents/grpc/src/proto/nsolid_service.grpc.pb.h index bca84ece8a4..aee2f39dbb7 100644 --- a/agents/grpc/src/proto/nsolid_service.grpc.pb.h +++ b/agents/grpc/src/proto/nsolid_service.grpc.pb.h @@ -102,6 +102,13 @@ class NSolidService final { std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> PrepareAsyncExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(PrepareAsyncExportReconfigureRaw(context, request, cq)); } + virtual ::grpc::Status ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpcagent::EventResponse* response) = 0; + std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> AsyncExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(AsyncExportSourceCodeRaw(context, request, cq)); + } + std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> PrepareAsyncExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(PrepareAsyncExportSourceCodeRaw(context, request, cq)); + } virtual ::grpc::Status ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpcagent::EventResponse* response) = 0; std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> AsyncExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(AsyncExportStartupTimesRaw(context, request, cq)); @@ -128,6 +135,8 @@ class NSolidService final { virtual void ExportUnblockedLoop(::grpc::ClientContext* context, const ::grpcagent::UnblockedLoopEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; virtual void ExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response, std::function) = 0; virtual void ExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; + virtual void ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, std::function) = 0; + virtual void ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; virtual void ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response, std::function) = 0; virtual void ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; }; @@ -155,6 +164,8 @@ class NSolidService final { virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportUnblockedLoopRaw(::grpc::ClientContext* context, const ::grpcagent::UnblockedLoopEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* AsyncExportReconfigureRaw(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportReconfigureRaw(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* AsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* AsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) = 0; }; @@ -228,6 +239,13 @@ class NSolidService final { std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> PrepareAsyncExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(PrepareAsyncExportReconfigureRaw(context, request, cq)); } + ::grpc::Status ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpcagent::EventResponse* response) override; + std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> AsyncExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(AsyncExportSourceCodeRaw(context, request, cq)); + } + std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> PrepareAsyncExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(PrepareAsyncExportSourceCodeRaw(context, request, cq)); + } ::grpc::Status ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpcagent::EventResponse* response) override; std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> AsyncExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(AsyncExportStartupTimesRaw(context, request, cq)); @@ -254,6 +272,8 @@ class NSolidService final { void ExportUnblockedLoop(::grpc::ClientContext* context, const ::grpcagent::UnblockedLoopEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; void ExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response, std::function) override; void ExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; + void ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, std::function) override; + void ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; void ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response, std::function) override; void ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; private: @@ -287,6 +307,8 @@ class NSolidService final { ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportUnblockedLoopRaw(::grpc::ClientContext* context, const ::grpcagent::UnblockedLoopEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* AsyncExportReconfigureRaw(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportReconfigureRaw(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) override; + ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* AsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) override; + ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* AsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) override; const ::grpc::internal::RpcMethod rpcmethod_Command_; @@ -298,6 +320,7 @@ class NSolidService final { const ::grpc::internal::RpcMethod rpcmethod_ExportBlockedLoop_; const ::grpc::internal::RpcMethod rpcmethod_ExportUnblockedLoop_; const ::grpc::internal::RpcMethod rpcmethod_ExportReconfigure_; + const ::grpc::internal::RpcMethod rpcmethod_ExportSourceCode_; const ::grpc::internal::RpcMethod rpcmethod_ExportStartupTimes_; }; static std::unique_ptr NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions()); @@ -315,6 +338,7 @@ class NSolidService final { virtual ::grpc::Status ExportBlockedLoop(::grpc::ServerContext* context, const ::grpcagent::BlockedLoopEvent* request, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportUnblockedLoop(::grpc::ServerContext* context, const ::grpcagent::UnblockedLoopEvent* request, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportReconfigure(::grpc::ServerContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response); + virtual ::grpc::Status ExportSourceCode(::grpc::ServerContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportStartupTimes(::grpc::ServerContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response); }; template @@ -498,12 +522,32 @@ class NSolidService final { } }; template + class WithAsyncMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithAsyncMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodAsync(9); + } + ~WithAsyncMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + void RequestExportSourceCode(::grpc::ServerContext* context, ::grpcagent::SourceCodeEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { + ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + } + }; + template class WithAsyncMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodAsync(9); + ::grpc::Service::MarkMethodAsync(10); } ~WithAsyncMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -514,10 +558,10 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportStartupTimes(::grpc::ServerContext* context, ::grpcagent::StartupTimesEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(10, context, request, response, new_call_cq, notification_cq, tag); } }; - typedef WithAsyncMethod_Command > > > > > > > > > AsyncService; + typedef WithAsyncMethod_Command > > > > > > > > > > AsyncService; template class WithCallbackMethod_Command : public BaseClass { private: @@ -753,18 +797,45 @@ class NSolidService final { ::grpc::CallbackServerContext* /*context*/, const ::grpcagent::ReconfigureEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } }; template + class WithCallbackMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithCallbackMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodCallback(9, + new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>( + [this]( + ::grpc::CallbackServerContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response) { return this->ExportSourceCode(context, request, response); }));} + void SetMessageAllocatorFor_ExportSourceCode( + ::grpc::MessageAllocator< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>* allocator) { + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(9); + static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>*>(handler) + ->SetMessageAllocator(allocator); + } + ~WithCallbackMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + virtual ::grpc::ServerUnaryReactor* ExportSourceCode( + ::grpc::CallbackServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } + }; + template class WithCallbackMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodCallback(9, + ::grpc::Service::MarkMethodCallback(10, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response) { return this->ExportStartupTimes(context, request, response); }));} void SetMessageAllocatorFor_ExportStartupTimes( ::grpc::MessageAllocator< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(9); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(10); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -779,7 +850,7 @@ class NSolidService final { virtual ::grpc::ServerUnaryReactor* ExportStartupTimes( ::grpc::CallbackServerContext* /*context*/, const ::grpcagent::StartupTimesEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } }; - typedef WithCallbackMethod_Command > > > > > > > > > CallbackService; + typedef WithCallbackMethod_Command > > > > > > > > > > CallbackService; typedef CallbackService ExperimentalCallbackService; template class WithGenericMethod_Command : public BaseClass { @@ -935,12 +1006,29 @@ class NSolidService final { } }; template + class WithGenericMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithGenericMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodGeneric(9); + } + ~WithGenericMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + }; + template class WithGenericMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodGeneric(9); + ::grpc::Service::MarkMethodGeneric(10); } ~WithGenericMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -1132,12 +1220,32 @@ class NSolidService final { } }; template + class WithRawMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithRawMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodRaw(9); + } + ~WithRawMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + void RequestExportSourceCode(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { + ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + } + }; + template class WithRawMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodRaw(9); + ::grpc::Service::MarkMethodRaw(10); } ~WithRawMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -1148,7 +1256,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportStartupTimes(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(10, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1351,12 +1459,34 @@ class NSolidService final { ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; } }; template + class WithRawCallbackMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithRawCallbackMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodRawCallback(9, + new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + [this]( + ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportSourceCode(context, request, response); })); + } + ~WithRawCallbackMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + virtual ::grpc::ServerUnaryReactor* ExportSourceCode( + ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; } + }; + template class WithRawCallbackMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodRawCallback(9, + ::grpc::Service::MarkMethodRawCallback(10, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportStartupTimes(context, request, response); })); @@ -1562,12 +1692,39 @@ class NSolidService final { virtual ::grpc::Status StreamedExportReconfigure(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpcagent::ReconfigureEvent,::grpcagent::EventResponse>* server_unary_streamer) = 0; }; template + class WithStreamedUnaryMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithStreamedUnaryMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodStreamed(9, + new ::grpc::internal::StreamedUnaryHandler< + ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>( + [this](::grpc::ServerContext* context, + ::grpc::ServerUnaryStreamer< + ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>* streamer) { + return this->StreamedExportSourceCode(context, + streamer); + })); + } + ~WithStreamedUnaryMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable regular version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + // replace default version of method with streamed unary + virtual ::grpc::Status StreamedExportSourceCode(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpcagent::SourceCodeEvent,::grpcagent::EventResponse>* server_unary_streamer) = 0; + }; + template class WithStreamedUnaryMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodStreamed(9, + ::grpc::Service::MarkMethodStreamed(10, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1588,9 +1745,9 @@ class NSolidService final { // replace default version of method with streamed unary virtual ::grpc::Status StreamedExportStartupTimes(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpcagent::StartupTimesEvent,::grpcagent::EventResponse>* server_unary_streamer) = 0; }; - typedef WithStreamedUnaryMethod_ExportExit > > > > > > > StreamedUnaryService; + typedef WithStreamedUnaryMethod_ExportExit > > > > > > > > StreamedUnaryService; typedef Service SplitStreamedService; - typedef WithStreamedUnaryMethod_ExportExit > > > > > > > StreamedService; + typedef WithStreamedUnaryMethod_ExportExit > > > > > > > > StreamedService; }; } // namespace grpcagent diff --git a/agents/grpc/src/proto/nsolid_service.pb.cc b/agents/grpc/src/proto/nsolid_service.pb.cc index 2c7ed41bf98..ed4780ba7b1 100644 --- a/agents/grpc/src/proto/nsolid_service.pb.cc +++ b/agents/grpc/src/proto/nsolid_service.pb.cc @@ -60,30 +60,32 @@ const char descriptor_table_protodef_nsolid_5fservice_2eproto[] PROTOBUF_SECTION "\n\024nsolid_service.proto\022\tgrpcagent\032\013asset" ".proto\032\022blocked_loop.proto\032\rcommand.prot" "o\032\nexit.proto\032\ninfo.proto\032\rmetrics.proto" - "\032\016packages.proto\032\021reconfigure.proto\032\023sta" - "rtup_times.proto\"&\n\rEventResponse\022\025\n\rerr" - "or_message\030\001 \001(\t2\342\005\n\rNSolidService\022F\n\007Co" - "mmand\022\032.grpcagent.CommandResponse\032\031.grpc" - "agent.CommandRequest\"\000(\0010\001\022=\n\013ExportAsse" - "t\022\020.grpcagent.Asset\032\030.grpcagent.EventRes" - "ponse\"\000(\001\022>\n\nExportExit\022\024.grpcagent.Exit" - "Event\032\030.grpcagent.EventResponse\"\000\022>\n\nExp" - "ortInfo\022\024.grpcagent.InfoEvent\032\030.grpcagen" - "t.EventResponse\"\000\022D\n\rExportMetrics\022\027.grp" - "cagent.MetricsEvent\032\030.grpcagent.EventRes" - "ponse\"\000\022F\n\016ExportPackages\022\030.grpcagent.Pa" - "ckagesEvent\032\030.grpcagent.EventResponse\"\000\022" - "L\n\021ExportBlockedLoop\022\033.grpcagent.Blocked" - "LoopEvent\032\030.grpcagent.EventResponse\"\000\022P\n" - "\023ExportUnblockedLoop\022\035.grpcagent.Unblock" - "edLoopEvent\032\030.grpcagent.EventResponse\"\000\022" - "L\n\021ExportReconfigure\022\033.grpcagent.Reconfi" - "gureEvent\032\030.grpcagent.EventResponse\"\000\022N\n" - "\022ExportStartupTimes\022\034.grpcagent.StartupT" - "imesEvent\032\030.grpcagent.EventResponse\"\000b\006p" - "roto3" + "\032\016packages.proto\032\021reconfigure.proto\032\021sou" + "rce_code.proto\032\023startup_times.proto\"&\n\rE" + "ventResponse\022\025\n\rerror_message\030\001 \001(\t2\256\006\n\r" + "NSolidService\022F\n\007Command\022\032.grpcagent.Com" + "mandResponse\032\031.grpcagent.CommandRequest\"" + "\000(\0010\001\022=\n\013ExportAsset\022\020.grpcagent.Asset\032\030" + ".grpcagent.EventResponse\"\000(\001\022>\n\nExportEx" + "it\022\024.grpcagent.ExitEvent\032\030.grpcagent.Eve" + "ntResponse\"\000\022>\n\nExportInfo\022\024.grpcagent.I" + "nfoEvent\032\030.grpcagent.EventResponse\"\000\022D\n\r" + "ExportMetrics\022\027.grpcagent.MetricsEvent\032\030" + ".grpcagent.EventResponse\"\000\022F\n\016ExportPack" + "ages\022\030.grpcagent.PackagesEvent\032\030.grpcage" + "nt.EventResponse\"\000\022L\n\021ExportBlockedLoop\022" + "\033.grpcagent.BlockedLoopEvent\032\030.grpcagent" + ".EventResponse\"\000\022P\n\023ExportUnblockedLoop\022" + "\035.grpcagent.UnblockedLoopEvent\032\030.grpcage" + "nt.EventResponse\"\000\022L\n\021ExportReconfigure\022" + "\033.grpcagent.ReconfigureEvent\032\030.grpcagent" + ".EventResponse\"\000\022J\n\020ExportSourceCode\022\032.g" + "rpcagent.SourceCodeEvent\032\030.grpcagent.Eve" + "ntResponse\"\000\022N\n\022ExportStartupTimes\022\034.grp" + "cagent.StartupTimesEvent\032\030.grpcagent.Eve" + "ntResponse\"\000b\006proto3" ; -static const ::_pbi::DescriptorTable* const descriptor_table_nsolid_5fservice_2eproto_deps[9] = { +static const ::_pbi::DescriptorTable* const descriptor_table_nsolid_5fservice_2eproto_deps[10] = { &::descriptor_table_asset_2eproto, &::descriptor_table_blocked_5floop_2eproto, &::descriptor_table_command_2eproto, @@ -92,13 +94,14 @@ static const ::_pbi::DescriptorTable* const descriptor_table_nsolid_5fservice_2e &::descriptor_table_metrics_2eproto, &::descriptor_table_packages_2eproto, &::descriptor_table_reconfigure_2eproto, + &::descriptor_table_source_5fcode_2eproto, &::descriptor_table_startup_5ftimes_2eproto, }; static ::_pbi::once_flag descriptor_table_nsolid_5fservice_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_nsolid_5fservice_2eproto = { - false, false, 965, descriptor_table_protodef_nsolid_5fservice_2eproto, + false, false, 1060, descriptor_table_protodef_nsolid_5fservice_2eproto, "nsolid_service.proto", - &descriptor_table_nsolid_5fservice_2eproto_once, descriptor_table_nsolid_5fservice_2eproto_deps, 9, 1, + &descriptor_table_nsolid_5fservice_2eproto_once, descriptor_table_nsolid_5fservice_2eproto_deps, 10, 1, schemas, file_default_instances, TableStruct_nsolid_5fservice_2eproto::offsets, file_level_metadata_nsolid_5fservice_2eproto, file_level_enum_descriptors_nsolid_5fservice_2eproto, file_level_service_descriptors_nsolid_5fservice_2eproto, diff --git a/agents/grpc/src/proto/nsolid_service.pb.h b/agents/grpc/src/proto/nsolid_service.pb.h index 5df81a6c465..65a4450741b 100644 --- a/agents/grpc/src/proto/nsolid_service.pb.h +++ b/agents/grpc/src/proto/nsolid_service.pb.h @@ -38,6 +38,7 @@ #include "metrics.pb.h" #include "packages.pb.h" #include "reconfigure.pb.h" +#include "source_code.pb.h" #include "startup_times.pb.h" // @@protoc_insertion_point(includes) #include diff --git a/agents/grpc/src/proto/source_code.grpc.pb.cc b/agents/grpc/src/proto/source_code.grpc.pb.cc new file mode 100644 index 00000000000..7e2ba7001b5 --- /dev/null +++ b/agents/grpc/src/proto/source_code.grpc.pb.cc @@ -0,0 +1,25 @@ +// Generated by the gRPC C++ plugin. +// If you make any local change, they will be lost. +// source: source_code.proto + +#include "source_code.pb.h" +#include "source_code.grpc.pb.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace grpcagent { + +} // namespace grpcagent + diff --git a/agents/grpc/src/proto/source_code.grpc.pb.h b/agents/grpc/src/proto/source_code.grpc.pb.h new file mode 100644 index 00000000000..31fb5e47c89 --- /dev/null +++ b/agents/grpc/src/proto/source_code.grpc.pb.h @@ -0,0 +1,33 @@ +// Generated by the gRPC C++ plugin. +// If you make any local change, they will be lost. +// source: source_code.proto +#ifndef GRPC_source_5fcode_2eproto__INCLUDED +#define GRPC_source_5fcode_2eproto__INCLUDED + +#include "source_code.pb.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpcagent { + +} // namespace grpcagent + + +#endif // GRPC_source_5fcode_2eproto__INCLUDED diff --git a/agents/grpc/src/proto/source_code.pb.cc b/agents/grpc/src/proto/source_code.pb.cc new file mode 100644 index 00000000000..c2aab9a101f --- /dev/null +++ b/agents/grpc/src/proto/source_code.pb.cc @@ -0,0 +1,759 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: source_code.proto + +#include "source_code.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include + +PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +namespace grpcagent { +PROTOBUF_CONSTEXPR SourceCodeArgs::SourceCodeArgs( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.path_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.thread_id_)*/int64_t{0} + , /*decltype(_impl_.script_id_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} +struct SourceCodeArgsDefaultTypeInternal { + PROTOBUF_CONSTEXPR SourceCodeArgsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~SourceCodeArgsDefaultTypeInternal() {} + union { + SourceCodeArgs _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeArgsDefaultTypeInternal _SourceCodeArgs_default_instance_; +PROTOBUF_CONSTEXPR SourceCodeEvent::SourceCodeEvent( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.path_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.code_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.common_)*/nullptr + , /*decltype(_impl_.thread_id_)*/int64_t{0} + , /*decltype(_impl_.is_esm_)*/false + , /*decltype(_impl_._cached_size_)*/{}} {} +struct SourceCodeEventDefaultTypeInternal { + PROTOBUF_CONSTEXPR SourceCodeEventDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~SourceCodeEventDefaultTypeInternal() {} + union { + SourceCodeEvent _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeEventDefaultTypeInternal _SourceCodeEvent_default_instance_; +} // namespace grpcagent +static ::_pb::Metadata file_level_metadata_source_5fcode_2eproto[2]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_source_5fcode_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_source_5fcode_2eproto = nullptr; + +const uint32_t TableStruct_source_5fcode_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeArgs, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeArgs, _impl_.thread_id_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeArgs, _impl_.script_id_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeArgs, _impl_.path_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.common_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.thread_id_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.path_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.code_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.is_esm_), +}; +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::grpcagent::SourceCodeArgs)}, + { 9, -1, -1, sizeof(::grpcagent::SourceCodeEvent)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::grpcagent::_SourceCodeArgs_default_instance_._instance, + &::grpcagent::_SourceCodeEvent_default_instance_._instance, +}; + +const char descriptor_table_protodef_source_5fcode_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\021source_code.proto\022\tgrpcagent\032\014common.p" + "roto\"D\n\016SourceCodeArgs\022\021\n\tthread_id\030\001 \001(" + "\003\022\021\n\tscript_id\030\002 \001(\005\022\014\n\004path\030\003 \001(\t\"{\n\017So" + "urceCodeEvent\022)\n\006common\030\001 \001(\0132\031.grpcagen" + "t.CommonResponse\022\021\n\tthread_id\030\002 \001(\003\022\014\n\004p" + "ath\030\003 \001(\t\022\014\n\004code\030\004 \001(\t\022\016\n\006is_esm\030\005 \001(\010b" + "\006proto3" + ; +static const ::_pbi::DescriptorTable* const descriptor_table_source_5fcode_2eproto_deps[1] = { + &::descriptor_table_common_2eproto, +}; +static ::_pbi::once_flag descriptor_table_source_5fcode_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_source_5fcode_2eproto = { + false, false, 247, descriptor_table_protodef_source_5fcode_2eproto, + "source_code.proto", + &descriptor_table_source_5fcode_2eproto_once, descriptor_table_source_5fcode_2eproto_deps, 1, 2, + schemas, file_default_instances, TableStruct_source_5fcode_2eproto::offsets, + file_level_metadata_source_5fcode_2eproto, file_level_enum_descriptors_source_5fcode_2eproto, + file_level_service_descriptors_source_5fcode_2eproto, +}; +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_source_5fcode_2eproto_getter() { + return &descriptor_table_source_5fcode_2eproto; +} + +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_source_5fcode_2eproto(&descriptor_table_source_5fcode_2eproto); +namespace grpcagent { + +// =================================================================== + +class SourceCodeArgs::_Internal { + public: +}; + +SourceCodeArgs::SourceCodeArgs(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:grpcagent.SourceCodeArgs) +} +SourceCodeArgs::SourceCodeArgs(const SourceCodeArgs& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + SourceCodeArgs* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.path_){} + , decltype(_impl_.thread_id_){} + , decltype(_impl_.script_id_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.path_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.path_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_path().empty()) { + _this->_impl_.path_.Set(from._internal_path(), + _this->GetArenaForAllocation()); + } + ::memcpy(&_impl_.thread_id_, &from._impl_.thread_id_, + static_cast(reinterpret_cast(&_impl_.script_id_) - + reinterpret_cast(&_impl_.thread_id_)) + sizeof(_impl_.script_id_)); + // @@protoc_insertion_point(copy_constructor:grpcagent.SourceCodeArgs) +} + +inline void SourceCodeArgs::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.path_){} + , decltype(_impl_.thread_id_){int64_t{0}} + , decltype(_impl_.script_id_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.path_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.path_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +SourceCodeArgs::~SourceCodeArgs() { + // @@protoc_insertion_point(destructor:grpcagent.SourceCodeArgs) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void SourceCodeArgs::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.path_.Destroy(); +} + +void SourceCodeArgs::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void SourceCodeArgs::Clear() { +// @@protoc_insertion_point(message_clear_start:grpcagent.SourceCodeArgs) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.path_.ClearToEmpty(); + ::memset(&_impl_.thread_id_, 0, static_cast( + reinterpret_cast(&_impl_.script_id_) - + reinterpret_cast(&_impl_.thread_id_)) + sizeof(_impl_.script_id_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* SourceCodeArgs::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int64 thread_id = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _impl_.thread_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // int32 script_id = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _impl_.script_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // string path = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_path(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "grpcagent.SourceCodeArgs.path")); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* SourceCodeArgs::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:grpcagent.SourceCodeArgs) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int64 thread_id = 1; + if (this->_internal_thread_id() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_thread_id(), target); + } + + // int32 script_id = 2; + if (this->_internal_script_id() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_script_id(), target); + } + + // string path = 3; + if (!this->_internal_path().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_path().data(), static_cast(this->_internal_path().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "grpcagent.SourceCodeArgs.path"); + target = stream->WriteStringMaybeAliased( + 3, this->_internal_path(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:grpcagent.SourceCodeArgs) + return target; +} + +size_t SourceCodeArgs::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:grpcagent.SourceCodeArgs) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string path = 3; + if (!this->_internal_path().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_path()); + } + + // int64 thread_id = 1; + if (this->_internal_thread_id() != 0) { + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_thread_id()); + } + + // int32 script_id = 2; + if (this->_internal_script_id() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_script_id()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SourceCodeArgs::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + SourceCodeArgs::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceCodeArgs::GetClassData() const { return &_class_data_; } + + +void SourceCodeArgs::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:grpcagent.SourceCodeArgs) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_path().empty()) { + _this->_internal_set_path(from._internal_path()); + } + if (from._internal_thread_id() != 0) { + _this->_internal_set_thread_id(from._internal_thread_id()); + } + if (from._internal_script_id() != 0) { + _this->_internal_set_script_id(from._internal_script_id()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void SourceCodeArgs::CopyFrom(const SourceCodeArgs& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpcagent.SourceCodeArgs) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool SourceCodeArgs::IsInitialized() const { + return true; +} + +void SourceCodeArgs::InternalSwap(SourceCodeArgs* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.path_, lhs_arena, + &other->_impl_.path_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(SourceCodeArgs, _impl_.script_id_) + + sizeof(SourceCodeArgs::_impl_.script_id_) + - PROTOBUF_FIELD_OFFSET(SourceCodeArgs, _impl_.thread_id_)>( + reinterpret_cast(&_impl_.thread_id_), + reinterpret_cast(&other->_impl_.thread_id_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeArgs::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_source_5fcode_2eproto_getter, &descriptor_table_source_5fcode_2eproto_once, + file_level_metadata_source_5fcode_2eproto[0]); +} + +// =================================================================== + +class SourceCodeEvent::_Internal { + public: + static const ::grpcagent::CommonResponse& common(const SourceCodeEvent* msg); +}; + +const ::grpcagent::CommonResponse& +SourceCodeEvent::_Internal::common(const SourceCodeEvent* msg) { + return *msg->_impl_.common_; +} +void SourceCodeEvent::clear_common() { + if (GetArenaForAllocation() == nullptr && _impl_.common_ != nullptr) { + delete _impl_.common_; + } + _impl_.common_ = nullptr; +} +SourceCodeEvent::SourceCodeEvent(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:grpcagent.SourceCodeEvent) +} +SourceCodeEvent::SourceCodeEvent(const SourceCodeEvent& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + SourceCodeEvent* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.path_){} + , decltype(_impl_.code_){} + , decltype(_impl_.common_){nullptr} + , decltype(_impl_.thread_id_){} + , decltype(_impl_.is_esm_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.path_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.path_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_path().empty()) { + _this->_impl_.path_.Set(from._internal_path(), + _this->GetArenaForAllocation()); + } + _impl_.code_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.code_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_code().empty()) { + _this->_impl_.code_.Set(from._internal_code(), + _this->GetArenaForAllocation()); + } + if (from._internal_has_common()) { + _this->_impl_.common_ = new ::grpcagent::CommonResponse(*from._impl_.common_); + } + ::memcpy(&_impl_.thread_id_, &from._impl_.thread_id_, + static_cast(reinterpret_cast(&_impl_.is_esm_) - + reinterpret_cast(&_impl_.thread_id_)) + sizeof(_impl_.is_esm_)); + // @@protoc_insertion_point(copy_constructor:grpcagent.SourceCodeEvent) +} + +inline void SourceCodeEvent::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.path_){} + , decltype(_impl_.code_){} + , decltype(_impl_.common_){nullptr} + , decltype(_impl_.thread_id_){int64_t{0}} + , decltype(_impl_.is_esm_){false} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.path_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.path_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.code_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.code_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +SourceCodeEvent::~SourceCodeEvent() { + // @@protoc_insertion_point(destructor:grpcagent.SourceCodeEvent) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void SourceCodeEvent::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.path_.Destroy(); + _impl_.code_.Destroy(); + if (this != internal_default_instance()) delete _impl_.common_; +} + +void SourceCodeEvent::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void SourceCodeEvent::Clear() { +// @@protoc_insertion_point(message_clear_start:grpcagent.SourceCodeEvent) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.path_.ClearToEmpty(); + _impl_.code_.ClearToEmpty(); + if (GetArenaForAllocation() == nullptr && _impl_.common_ != nullptr) { + delete _impl_.common_; + } + _impl_.common_ = nullptr; + ::memset(&_impl_.thread_id_, 0, static_cast( + reinterpret_cast(&_impl_.is_esm_) - + reinterpret_cast(&_impl_.thread_id_)) + sizeof(_impl_.is_esm_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* SourceCodeEvent::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // .grpcagent.CommonResponse common = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_common(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // int64 thread_id = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _impl_.thread_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // string path = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_path(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "grpcagent.SourceCodeEvent.path")); + } else + goto handle_unusual; + continue; + // string code = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + auto str = _internal_mutable_code(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "grpcagent.SourceCodeEvent.code")); + } else + goto handle_unusual; + continue; + // bool is_esm = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { + _impl_.is_esm_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* SourceCodeEvent::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:grpcagent.SourceCodeEvent) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // .grpcagent.CommonResponse common = 1; + if (this->_internal_has_common()) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::common(this), + _Internal::common(this).GetCachedSize(), target, stream); + } + + // int64 thread_id = 2; + if (this->_internal_thread_id() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_thread_id(), target); + } + + // string path = 3; + if (!this->_internal_path().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_path().data(), static_cast(this->_internal_path().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "grpcagent.SourceCodeEvent.path"); + target = stream->WriteStringMaybeAliased( + 3, this->_internal_path(), target); + } + + // string code = 4; + if (!this->_internal_code().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_code().data(), static_cast(this->_internal_code().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "grpcagent.SourceCodeEvent.code"); + target = stream->WriteStringMaybeAliased( + 4, this->_internal_code(), target); + } + + // bool is_esm = 5; + if (this->_internal_is_esm() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_is_esm(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:grpcagent.SourceCodeEvent) + return target; +} + +size_t SourceCodeEvent::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:grpcagent.SourceCodeEvent) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string path = 3; + if (!this->_internal_path().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_path()); + } + + // string code = 4; + if (!this->_internal_code().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_code()); + } + + // .grpcagent.CommonResponse common = 1; + if (this->_internal_has_common()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.common_); + } + + // int64 thread_id = 2; + if (this->_internal_thread_id() != 0) { + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_thread_id()); + } + + // bool is_esm = 5; + if (this->_internal_is_esm() != 0) { + total_size += 1 + 1; + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SourceCodeEvent::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + SourceCodeEvent::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceCodeEvent::GetClassData() const { return &_class_data_; } + + +void SourceCodeEvent::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:grpcagent.SourceCodeEvent) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_path().empty()) { + _this->_internal_set_path(from._internal_path()); + } + if (!from._internal_code().empty()) { + _this->_internal_set_code(from._internal_code()); + } + if (from._internal_has_common()) { + _this->_internal_mutable_common()->::grpcagent::CommonResponse::MergeFrom( + from._internal_common()); + } + if (from._internal_thread_id() != 0) { + _this->_internal_set_thread_id(from._internal_thread_id()); + } + if (from._internal_is_esm() != 0) { + _this->_internal_set_is_esm(from._internal_is_esm()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void SourceCodeEvent::CopyFrom(const SourceCodeEvent& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpcagent.SourceCodeEvent) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool SourceCodeEvent::IsInitialized() const { + return true; +} + +void SourceCodeEvent::InternalSwap(SourceCodeEvent* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.path_, lhs_arena, + &other->_impl_.path_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.code_, lhs_arena, + &other->_impl_.code_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(SourceCodeEvent, _impl_.is_esm_) + + sizeof(SourceCodeEvent::_impl_.is_esm_) + - PROTOBUF_FIELD_OFFSET(SourceCodeEvent, _impl_.common_)>( + reinterpret_cast(&_impl_.common_), + reinterpret_cast(&other->_impl_.common_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeEvent::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_source_5fcode_2eproto_getter, &descriptor_table_source_5fcode_2eproto_once, + file_level_metadata_source_5fcode_2eproto[1]); +} + +// @@protoc_insertion_point(namespace_scope) +} // namespace grpcagent +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::grpcagent::SourceCodeArgs* +Arena::CreateMaybeMessage< ::grpcagent::SourceCodeArgs >(Arena* arena) { + return Arena::CreateMessageInternal< ::grpcagent::SourceCodeArgs >(arena); +} +template<> PROTOBUF_NOINLINE ::grpcagent::SourceCodeEvent* +Arena::CreateMaybeMessage< ::grpcagent::SourceCodeEvent >(Arena* arena) { + return Arena::CreateMessageInternal< ::grpcagent::SourceCodeEvent >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/agents/grpc/src/proto/source_code.pb.h b/agents/grpc/src/proto/source_code.pb.h new file mode 100644 index 00000000000..eb1f2a2a956 --- /dev/null +++ b/agents/grpc/src/proto/source_code.pb.h @@ -0,0 +1,791 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: source_code.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_source_5fcode_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_source_5fcode_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3021000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "common.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_source_5fcode_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_source_5fcode_2eproto { + static const uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_source_5fcode_2eproto; +namespace grpcagent { +class SourceCodeArgs; +struct SourceCodeArgsDefaultTypeInternal; +extern SourceCodeArgsDefaultTypeInternal _SourceCodeArgs_default_instance_; +class SourceCodeEvent; +struct SourceCodeEventDefaultTypeInternal; +extern SourceCodeEventDefaultTypeInternal _SourceCodeEvent_default_instance_; +} // namespace grpcagent +PROTOBUF_NAMESPACE_OPEN +template<> ::grpcagent::SourceCodeArgs* Arena::CreateMaybeMessage<::grpcagent::SourceCodeArgs>(Arena*); +template<> ::grpcagent::SourceCodeEvent* Arena::CreateMaybeMessage<::grpcagent::SourceCodeEvent>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace grpcagent { + +// =================================================================== + +class SourceCodeArgs final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:grpcagent.SourceCodeArgs) */ { + public: + inline SourceCodeArgs() : SourceCodeArgs(nullptr) {} + ~SourceCodeArgs() override; + explicit PROTOBUF_CONSTEXPR SourceCodeArgs(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + SourceCodeArgs(const SourceCodeArgs& from); + SourceCodeArgs(SourceCodeArgs&& from) noexcept + : SourceCodeArgs() { + *this = ::std::move(from); + } + + inline SourceCodeArgs& operator=(const SourceCodeArgs& from) { + CopyFrom(from); + return *this; + } + inline SourceCodeArgs& operator=(SourceCodeArgs&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const SourceCodeArgs& default_instance() { + return *internal_default_instance(); + } + static inline const SourceCodeArgs* internal_default_instance() { + return reinterpret_cast( + &_SourceCodeArgs_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(SourceCodeArgs& a, SourceCodeArgs& b) { + a.Swap(&b); + } + inline void Swap(SourceCodeArgs* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SourceCodeArgs* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + SourceCodeArgs* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const SourceCodeArgs& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const SourceCodeArgs& from) { + SourceCodeArgs::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(SourceCodeArgs* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "grpcagent.SourceCodeArgs"; + } + protected: + explicit SourceCodeArgs(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kPathFieldNumber = 3, + kThreadIdFieldNumber = 1, + kScriptIdFieldNumber = 2, + }; + // string path = 3; + void clear_path(); + const std::string& path() const; + template + void set_path(ArgT0&& arg0, ArgT... args); + std::string* mutable_path(); + PROTOBUF_NODISCARD std::string* release_path(); + void set_allocated_path(std::string* path); + private: + const std::string& _internal_path() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_path(const std::string& value); + std::string* _internal_mutable_path(); + public: + + // int64 thread_id = 1; + void clear_thread_id(); + int64_t thread_id() const; + void set_thread_id(int64_t value); + private: + int64_t _internal_thread_id() const; + void _internal_set_thread_id(int64_t value); + public: + + // int32 script_id = 2; + void clear_script_id(); + int32_t script_id() const; + void set_script_id(int32_t value); + private: + int32_t _internal_script_id() const; + void _internal_set_script_id(int32_t value); + public: + + // @@protoc_insertion_point(class_scope:grpcagent.SourceCodeArgs) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr path_; + int64_t thread_id_; + int32_t script_id_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_source_5fcode_2eproto; +}; +// ------------------------------------------------------------------- + +class SourceCodeEvent final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:grpcagent.SourceCodeEvent) */ { + public: + inline SourceCodeEvent() : SourceCodeEvent(nullptr) {} + ~SourceCodeEvent() override; + explicit PROTOBUF_CONSTEXPR SourceCodeEvent(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + SourceCodeEvent(const SourceCodeEvent& from); + SourceCodeEvent(SourceCodeEvent&& from) noexcept + : SourceCodeEvent() { + *this = ::std::move(from); + } + + inline SourceCodeEvent& operator=(const SourceCodeEvent& from) { + CopyFrom(from); + return *this; + } + inline SourceCodeEvent& operator=(SourceCodeEvent&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const SourceCodeEvent& default_instance() { + return *internal_default_instance(); + } + static inline const SourceCodeEvent* internal_default_instance() { + return reinterpret_cast( + &_SourceCodeEvent_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(SourceCodeEvent& a, SourceCodeEvent& b) { + a.Swap(&b); + } + inline void Swap(SourceCodeEvent* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SourceCodeEvent* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + SourceCodeEvent* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const SourceCodeEvent& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const SourceCodeEvent& from) { + SourceCodeEvent::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(SourceCodeEvent* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "grpcagent.SourceCodeEvent"; + } + protected: + explicit SourceCodeEvent(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kPathFieldNumber = 3, + kCodeFieldNumber = 4, + kCommonFieldNumber = 1, + kThreadIdFieldNumber = 2, + kIsEsmFieldNumber = 5, + }; + // string path = 3; + void clear_path(); + const std::string& path() const; + template + void set_path(ArgT0&& arg0, ArgT... args); + std::string* mutable_path(); + PROTOBUF_NODISCARD std::string* release_path(); + void set_allocated_path(std::string* path); + private: + const std::string& _internal_path() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_path(const std::string& value); + std::string* _internal_mutable_path(); + public: + + // string code = 4; + void clear_code(); + const std::string& code() const; + template + void set_code(ArgT0&& arg0, ArgT... args); + std::string* mutable_code(); + PROTOBUF_NODISCARD std::string* release_code(); + void set_allocated_code(std::string* code); + private: + const std::string& _internal_code() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_code(const std::string& value); + std::string* _internal_mutable_code(); + public: + + // .grpcagent.CommonResponse common = 1; + bool has_common() const; + private: + bool _internal_has_common() const; + public: + void clear_common(); + const ::grpcagent::CommonResponse& common() const; + PROTOBUF_NODISCARD ::grpcagent::CommonResponse* release_common(); + ::grpcagent::CommonResponse* mutable_common(); + void set_allocated_common(::grpcagent::CommonResponse* common); + private: + const ::grpcagent::CommonResponse& _internal_common() const; + ::grpcagent::CommonResponse* _internal_mutable_common(); + public: + void unsafe_arena_set_allocated_common( + ::grpcagent::CommonResponse* common); + ::grpcagent::CommonResponse* unsafe_arena_release_common(); + + // int64 thread_id = 2; + void clear_thread_id(); + int64_t thread_id() const; + void set_thread_id(int64_t value); + private: + int64_t _internal_thread_id() const; + void _internal_set_thread_id(int64_t value); + public: + + // bool is_esm = 5; + void clear_is_esm(); + bool is_esm() const; + void set_is_esm(bool value); + private: + bool _internal_is_esm() const; + void _internal_set_is_esm(bool value); + public: + + // @@protoc_insertion_point(class_scope:grpcagent.SourceCodeEvent) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr path_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr code_; + ::grpcagent::CommonResponse* common_; + int64_t thread_id_; + bool is_esm_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_source_5fcode_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// SourceCodeArgs + +// int64 thread_id = 1; +inline void SourceCodeArgs::clear_thread_id() { + _impl_.thread_id_ = int64_t{0}; +} +inline int64_t SourceCodeArgs::_internal_thread_id() const { + return _impl_.thread_id_; +} +inline int64_t SourceCodeArgs::thread_id() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeArgs.thread_id) + return _internal_thread_id(); +} +inline void SourceCodeArgs::_internal_set_thread_id(int64_t value) { + + _impl_.thread_id_ = value; +} +inline void SourceCodeArgs::set_thread_id(int64_t value) { + _internal_set_thread_id(value); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeArgs.thread_id) +} + +// int32 script_id = 2; +inline void SourceCodeArgs::clear_script_id() { + _impl_.script_id_ = 0; +} +inline int32_t SourceCodeArgs::_internal_script_id() const { + return _impl_.script_id_; +} +inline int32_t SourceCodeArgs::script_id() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeArgs.script_id) + return _internal_script_id(); +} +inline void SourceCodeArgs::_internal_set_script_id(int32_t value) { + + _impl_.script_id_ = value; +} +inline void SourceCodeArgs::set_script_id(int32_t value) { + _internal_set_script_id(value); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeArgs.script_id) +} + +// string path = 3; +inline void SourceCodeArgs::clear_path() { + _impl_.path_.ClearToEmpty(); +} +inline const std::string& SourceCodeArgs::path() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeArgs.path) + return _internal_path(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void SourceCodeArgs::set_path(ArgT0&& arg0, ArgT... args) { + + _impl_.path_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeArgs.path) +} +inline std::string* SourceCodeArgs::mutable_path() { + std::string* _s = _internal_mutable_path(); + // @@protoc_insertion_point(field_mutable:grpcagent.SourceCodeArgs.path) + return _s; +} +inline const std::string& SourceCodeArgs::_internal_path() const { + return _impl_.path_.Get(); +} +inline void SourceCodeArgs::_internal_set_path(const std::string& value) { + + _impl_.path_.Set(value, GetArenaForAllocation()); +} +inline std::string* SourceCodeArgs::_internal_mutable_path() { + + return _impl_.path_.Mutable(GetArenaForAllocation()); +} +inline std::string* SourceCodeArgs::release_path() { + // @@protoc_insertion_point(field_release:grpcagent.SourceCodeArgs.path) + return _impl_.path_.Release(); +} +inline void SourceCodeArgs::set_allocated_path(std::string* path) { + if (path != nullptr) { + + } else { + + } + _impl_.path_.SetAllocated(path, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.path_.IsDefault()) { + _impl_.path_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:grpcagent.SourceCodeArgs.path) +} + +// ------------------------------------------------------------------- + +// SourceCodeEvent + +// .grpcagent.CommonResponse common = 1; +inline bool SourceCodeEvent::_internal_has_common() const { + return this != internal_default_instance() && _impl_.common_ != nullptr; +} +inline bool SourceCodeEvent::has_common() const { + return _internal_has_common(); +} +inline const ::grpcagent::CommonResponse& SourceCodeEvent::_internal_common() const { + const ::grpcagent::CommonResponse* p = _impl_.common_; + return p != nullptr ? *p : reinterpret_cast( + ::grpcagent::_CommonResponse_default_instance_); +} +inline const ::grpcagent::CommonResponse& SourceCodeEvent::common() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.common) + return _internal_common(); +} +inline void SourceCodeEvent::unsafe_arena_set_allocated_common( + ::grpcagent::CommonResponse* common) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.common_); + } + _impl_.common_ = common; + if (common) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:grpcagent.SourceCodeEvent.common) +} +inline ::grpcagent::CommonResponse* SourceCodeEvent::release_common() { + + ::grpcagent::CommonResponse* temp = _impl_.common_; + _impl_.common_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::grpcagent::CommonResponse* SourceCodeEvent::unsafe_arena_release_common() { + // @@protoc_insertion_point(field_release:grpcagent.SourceCodeEvent.common) + + ::grpcagent::CommonResponse* temp = _impl_.common_; + _impl_.common_ = nullptr; + return temp; +} +inline ::grpcagent::CommonResponse* SourceCodeEvent::_internal_mutable_common() { + + if (_impl_.common_ == nullptr) { + auto* p = CreateMaybeMessage<::grpcagent::CommonResponse>(GetArenaForAllocation()); + _impl_.common_ = p; + } + return _impl_.common_; +} +inline ::grpcagent::CommonResponse* SourceCodeEvent::mutable_common() { + ::grpcagent::CommonResponse* _msg = _internal_mutable_common(); + // @@protoc_insertion_point(field_mutable:grpcagent.SourceCodeEvent.common) + return _msg; +} +inline void SourceCodeEvent::set_allocated_common(::grpcagent::CommonResponse* common) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.common_); + } + if (common) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(common)); + if (message_arena != submessage_arena) { + common = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, common, submessage_arena); + } + + } else { + + } + _impl_.common_ = common; + // @@protoc_insertion_point(field_set_allocated:grpcagent.SourceCodeEvent.common) +} + +// int64 thread_id = 2; +inline void SourceCodeEvent::clear_thread_id() { + _impl_.thread_id_ = int64_t{0}; +} +inline int64_t SourceCodeEvent::_internal_thread_id() const { + return _impl_.thread_id_; +} +inline int64_t SourceCodeEvent::thread_id() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.thread_id) + return _internal_thread_id(); +} +inline void SourceCodeEvent::_internal_set_thread_id(int64_t value) { + + _impl_.thread_id_ = value; +} +inline void SourceCodeEvent::set_thread_id(int64_t value) { + _internal_set_thread_id(value); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeEvent.thread_id) +} + +// string path = 3; +inline void SourceCodeEvent::clear_path() { + _impl_.path_.ClearToEmpty(); +} +inline const std::string& SourceCodeEvent::path() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.path) + return _internal_path(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void SourceCodeEvent::set_path(ArgT0&& arg0, ArgT... args) { + + _impl_.path_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeEvent.path) +} +inline std::string* SourceCodeEvent::mutable_path() { + std::string* _s = _internal_mutable_path(); + // @@protoc_insertion_point(field_mutable:grpcagent.SourceCodeEvent.path) + return _s; +} +inline const std::string& SourceCodeEvent::_internal_path() const { + return _impl_.path_.Get(); +} +inline void SourceCodeEvent::_internal_set_path(const std::string& value) { + + _impl_.path_.Set(value, GetArenaForAllocation()); +} +inline std::string* SourceCodeEvent::_internal_mutable_path() { + + return _impl_.path_.Mutable(GetArenaForAllocation()); +} +inline std::string* SourceCodeEvent::release_path() { + // @@protoc_insertion_point(field_release:grpcagent.SourceCodeEvent.path) + return _impl_.path_.Release(); +} +inline void SourceCodeEvent::set_allocated_path(std::string* path) { + if (path != nullptr) { + + } else { + + } + _impl_.path_.SetAllocated(path, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.path_.IsDefault()) { + _impl_.path_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:grpcagent.SourceCodeEvent.path) +} + +// string code = 4; +inline void SourceCodeEvent::clear_code() { + _impl_.code_.ClearToEmpty(); +} +inline const std::string& SourceCodeEvent::code() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.code) + return _internal_code(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void SourceCodeEvent::set_code(ArgT0&& arg0, ArgT... args) { + + _impl_.code_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeEvent.code) +} +inline std::string* SourceCodeEvent::mutable_code() { + std::string* _s = _internal_mutable_code(); + // @@protoc_insertion_point(field_mutable:grpcagent.SourceCodeEvent.code) + return _s; +} +inline const std::string& SourceCodeEvent::_internal_code() const { + return _impl_.code_.Get(); +} +inline void SourceCodeEvent::_internal_set_code(const std::string& value) { + + _impl_.code_.Set(value, GetArenaForAllocation()); +} +inline std::string* SourceCodeEvent::_internal_mutable_code() { + + return _impl_.code_.Mutable(GetArenaForAllocation()); +} +inline std::string* SourceCodeEvent::release_code() { + // @@protoc_insertion_point(field_release:grpcagent.SourceCodeEvent.code) + return _impl_.code_.Release(); +} +inline void SourceCodeEvent::set_allocated_code(std::string* code) { + if (code != nullptr) { + + } else { + + } + _impl_.code_.SetAllocated(code, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.code_.IsDefault()) { + _impl_.code_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:grpcagent.SourceCodeEvent.code) +} + +// bool is_esm = 5; +inline void SourceCodeEvent::clear_is_esm() { + _impl_.is_esm_ = false; +} +inline bool SourceCodeEvent::_internal_is_esm() const { + return _impl_.is_esm_; +} +inline bool SourceCodeEvent::is_esm() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.is_esm) + return _internal_is_esm(); +} +inline void SourceCodeEvent::_internal_set_is_esm(bool value) { + + _impl_.is_esm_ = value; +} +inline void SourceCodeEvent::set_is_esm(bool value) { + _internal_set_is_esm(value); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeEvent.is_esm) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace grpcagent + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_source_5fcode_2eproto diff --git a/node.gyp b/node.gyp index 2e9fd14b109..2a00cca2786 100644 --- a/node.gyp +++ b/node.gyp @@ -429,6 +429,8 @@ 'agents/grpc/src/proto/profile.pb.cc', 'agents/grpc/src/proto/reconfigure.grpc.pb.cc', 'agents/grpc/src/proto/reconfigure.pb.cc', + 'agents/grpc/src/proto/source_code.grpc.pb.cc', + 'agents/grpc/src/proto/source_code.pb.cc', 'agents/grpc/src/proto/startup_times.grpc.pb.cc', 'agents/grpc/src/proto/startup_times.pb.cc', 'agents/grpc/src/proto/nsolid_service.grpc.pb.h', @@ -453,6 +455,8 @@ 'agents/grpc/src/proto/profile.pb.h', 'agents/grpc/src/proto/reconfigure.grpc.pb.h', 'agents/grpc/src/proto/reconfigure.pb.h', + 'agents/grpc/src/proto/source_code.grpc.pb.h', + 'agents/grpc/src/proto/source_code.pb.h', 'agents/grpc/src/proto/startup_times.grpc.pb.h', 'agents/grpc/src/proto/startup_times.pb.h', 'agents/otlp/src/datadog_metrics.cc', diff --git a/src/module_wrap.cc b/src/module_wrap.cc index eea74bed4bb..c159bc640e1 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -9,6 +9,7 @@ #include "node_process-inl.h" #include "node_watchdog.h" #include "util-inl.h" +#include "nsolid/nsolid_api.h" #include // S_IFDIR @@ -245,6 +246,9 @@ void ModuleWrap::New(const FunctionCallbackInfo& args) { .IsNothing()) { return; } + + auto envinst = nsolid::EnvInst::GetCurrent(isolate); + envinst->StoreSourceCode(module->ScriptId(), url, source_text, true); } } diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 8951cd378a9..eecf1cf94e7 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -32,6 +32,7 @@ #include "node_snapshot_builder.h" #include "node_watchdog.h" #include "util-inl.h" +#include "nsolid/nsolid_api.h" namespace node { namespace contextify { @@ -1696,6 +1697,10 @@ static void CompileFunctionForCJSLoader( }; Local result = Object::New( isolate, v8::Null(isolate), names.data(), values.data(), names.size()); + + auto envinst = nsolid::EnvInst::GetCurrent(isolate); + envinst->StoreSourceCode(fn->ScriptId(), filename, code, false); + args.GetReturnValue().Set(result); } diff --git a/src/nsolid/nsolid_api.cc b/src/nsolid/nsolid_api.cc index 0dbfadfef80..d90f93df655 100644 --- a/src/nsolid/nsolid_api.cc +++ b/src/nsolid/nsolid_api.cc @@ -121,6 +121,8 @@ EnvInst::EnvInst(Environment* env) CHECK_EQ(er, 0); er = custom_command_stor_map_lock_.init(true); CHECK_EQ(er, 0); + er = source_files_lock_.init(true); + CHECK_EQ(er, 0); eloop_cmds_msg_.unref(); interrupt_msg_.unref(); @@ -761,6 +763,67 @@ int EnvInst::CustomCommandResponse(const std::string& req_id, } +int EnvInst::GetSourceCode(int script_id, + const std::string& path, + std::string* code) { + SourceCodeInfo info; + { + ns_mutex::scoped_lock lock(source_files_lock_); + auto it = source_files_.find(script_id); + if (it == source_files_.end()) { + return UV_ENOENT; + } + + info = it->second; + } + + if (info.url != path) { + return UV_ENOENT; + } + + if (!info.code.empty()) { + *code = info.code; + return 0; + } + + std::string real_path; + if (info.is_esm && path.find("file://") == 0) { + real_path = path.substr(7); + } else { + real_path = path; + } + + return ReadFileSync(code, real_path.c_str());; +} + + +void EnvInst::StoreSourceCode(int script_id, + v8::Local url, + v8::Local code, + bool is_esm) { + if (url.IsEmpty() || code.IsEmpty()) { + return; + } + + // fprintf(stderr, "[%d][%ld] StoreSourceCode: %s\n", script_id, thread_id_, + // *Utf8Value(isolate_, url)); + ns_mutex::scoped_lock lock(source_files_lock_); + auto pair = source_files_.try_emplace(script_id, SourceCodeInfo{}); + if (!pair.second) { + return; + } + + SourceCodeInfo& info = pair.first->second; + info.url = *Utf8Value(isolate_, url); + if (is_esm && info.url.find("file://") != 0) { + // If the URL is not a file URL, store the code. + info.code = *Utf8Value(isolate_, code); + } + + info.is_esm = is_esm; +} + + EnvList::EnvList(): info_(nlohmann::json()) { int er; // Create event loop and new thread to run EnvList commands. @@ -2690,6 +2753,7 @@ static void HeapSampling(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(ret); } + static void HeapSamplingEnd(const FunctionCallbackInfo& args) { CHECK(args[0]->IsNumber()); // thread_id uint64_t thread_id = args[0].As()->Value(); diff --git a/src/nsolid/nsolid_api.h b/src/nsolid/nsolid_api.h index 20bf4da9aee..0198ede2540 100644 --- a/src/nsolid/nsolid_api.h +++ b/src/nsolid/nsolid_api.h @@ -229,6 +229,14 @@ class EnvInst { std::string GetThreadName() const; void SetThreadName(const std::string& name); + int GetSourceCode(int script_id, + const std::string& path, + std::string* code); + void StoreSourceCode(int script_id, + v8::Local url, + v8::Local code, + bool is_esm); + void inc_fs_handles_closed() { fs_handles_closed_++; } void inc_fs_handles_opened() { fs_handles_opened_++; } @@ -286,6 +294,12 @@ class EnvInst { friend class ThreadMetrics; friend class std::shared_ptr; + struct SourceCodeInfo { + std::string url; + std::string code; + bool is_esm; + }; + explicit EnvInst(Environment* env); ~EnvInst() = default; @@ -395,6 +409,9 @@ class EnvInst { std::string thread_name_; uint32_t trace_flags_; bool has_metrics_stream_hooks_; + + nsuv::ns_mutex source_files_lock_; + std::map source_files_; }; /** diff --git a/test/agents/test-grpc-source-code.mjs b/test/agents/test-grpc-source-code.mjs new file mode 100644 index 00000000000..8c891fd4da7 --- /dev/null +++ b/test/agents/test-grpc-source-code.mjs @@ -0,0 +1,340 @@ +// Flags: --expose-internals +import { mustCall, mustSucceed } from '../common/index.mjs'; +import { fixturesDir } from '../common/fixtures.mjs'; +import assert from 'node:assert'; +import fs from 'node:fs'; +import path from 'node:path'; +import validators from 'internal/validators'; +import { + GRPCServer, + TestClient, +} from '../common/nsolid-grpc-agent/index.js'; + +const { + validateArray, + validateObject, + validateString, +} = validators; + +function checkSourceCodeData(sourceCode, metadata, requestId, agentId, options) { + // console.dir(sourceCode, { depth: null }); + validateString(sourceCode.common.requestId, 'requestId'); + assert.ok(sourceCode.common.requestId.length > 0); + if (requestId) { + assert.strictEqual(sourceCode.common.requestId, requestId); + } + + assert.strictEqual(sourceCode.common.command, 'source_code'); + // From here check at least that all the fields are present + validateObject(sourceCode.common.recorded, 'recorded'); + const recSeconds = BigInt(sourceCode.common.recorded.seconds); + assert.ok(recSeconds); + const recNanoSecs = BigInt(sourceCode.common.recorded.nanoseconds); + assert.ok(recNanoSecs); + + assert.toString(sourceCode.threadId, options.threadId); + assert.strictEqual(sourceCode.path, options.path); + let realPath = options.path; + if (realPath.startsWith('file://')) { + realPath = realPath.substring(7); + } + + if (realPath.startsWith('data:text/javascript,')) { + assert.strictEqual(sourceCode.code, realPath.substring(21)); + } else { + assert.strictEqual(fs.readFileSync(realPath).toString(), sourceCode.code); + } + + + validateArray(metadata['user-agent'], 'metadata.user-agent'); + validateString(metadata['user-agent'][0], 'metadata.user-agent[0]'); + assert.strictEqual(metadata['nsolid-agent-id'][0], agentId); +} + +function checkSourceCodeError(sourceCode, metadata, requestId, agentId, code, msg) { + console.dir(sourceCode, { depth: null }); + assert.strictEqual(sourceCode.common.requestId, requestId); + assert.strictEqual(sourceCode.common.command, 'source_code'); + // From here check at least that all the fields are present + validateObject(sourceCode.common.recorded, 'recorded'); + const recSeconds = BigInt(sourceCode.common.recorded.seconds); + assert.ok(recSeconds); + const recNanoSecs = BigInt(sourceCode.common.recorded.nanoseconds); + assert.ok(recNanoSecs); + + validateObject(sourceCode.common.error, 'error'); + assert.strictEqual(sourceCode.common.error.code, code); + assert.strictEqual(sourceCode.common.error.message, msg); + + validateArray(metadata['user-agent'], 'metadata.user-agent'); + validateString(metadata['user-agent'][0], 'metadata.user-agent[0]'); + assert.strictEqual(metadata['nsolid-agent-id'][0], agentId); +} + +const tests = []; + +tests.push({ + name: 'should work for both cjs and esm scripts and fail for non-existent scripts on the main thread', + test: async () => { + return new Promise((resolve) => { + const importPath = path.join(fixturesDir, 'nsolid-source-code', 'index.mjs'); + const esmPath = path.join(fixturesDir, 'nsolid-source-code', 'esm.mjs'); + const commonPath = path.join(fixturesDir, 'nsolid-source-code', 'common.js'); + const grpcServer = new GRPCServer(); + grpcServer.start(mustSucceed(async (port) => { + grpcServer.on('loop_blocked', mustCall(async (data) => { + console.dir(data.msg, { depth: null }); + const scripts = []; + for (const frame of data.msg.body.stack) { + if (frame.scriptName.includes('client.js') || + frame.scriptName.includes(importPath) || + frame.scriptName.includes(esmPath) || + frame.scriptName.includes(commonPath)) { + scripts.push({ + scriptId: frame.scriptId, + path: frame.scriptName, + }); + } + } + + assert.strictEqual(scripts.length, 4); + for (const { scriptId, path } of scripts) { + const options = { + threadId: 0, + scriptId, + path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeData(ret.data.msg, ret.data.metadata, ret.requestId, agentId, options); + } + + // It should fail for a non-existent script + { + const options = { + threadId: 0, + scriptId: 0, + path: 'non-existent', + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 500, + 'Internal Runtime Error(1007)'); + } + + // It should also fail for a non-existent scriptId + { + const options = { + threadId: 0, + scriptId: 10000, + path: scripts[0].path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 500, + 'Internal Runtime Error(1007)'); + } + + // It should also fail for a non-existent thread + { + const options = { + threadId: 23, + scriptId: 10000, + path: scripts[0].path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 410, + 'Thread already gone(1002)'); + } + + await child.shutdown(0); + grpcServer.close(); + resolve(); + })); + + const env = { + NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', + NSOLID_GRPC_INSECURE: 1, + NSOLID_GRPC: `localhost:${port}`, + }; + + const opts = { + stdio: ['inherit', 'inherit', 'inherit', 'ipc'], + env, + }; + const child = new TestClient([], opts); + const agentId = await child.id(); + await child.importURL(importPath, 0); + })); + }); + }, +}); + +tests.push({ + name: 'should work for both cjs and esm scripts and fail for non-existent scripts on a worker thread', + test: async () => { + return new Promise((resolve) => { + const importPath = path.join(fixturesDir, 'nsolid-source-code', 'index.mjs'); + const esmPath = path.join(fixturesDir, 'nsolid-source-code', 'esm.mjs'); + const commonPath = path.join(fixturesDir, 'nsolid-source-code', 'common.js'); + const grpcServer = new GRPCServer(); + grpcServer.start(mustSucceed(async (port) => { + grpcServer.on('loop_blocked', mustCall(async (data) => { + console.dir(data.msg, { depth: null }); + const scripts = []; + for (const frame of data.msg.body.stack) { + if (frame.scriptName.includes('client.js') || + frame.scriptName.includes(importPath) || + frame.scriptName.includes(esmPath) || + frame.scriptName.includes(commonPath)) { + scripts.push({ + scriptId: frame.scriptId, + path: frame.scriptName, + }); + } + } + + assert.strictEqual(scripts.length, 4); + for (const { scriptId, path } of scripts) { + const options = { + threadId: wid, + scriptId, + path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeData(ret.data.msg, ret.data.metadata, ret.requestId, agentId, options); + } + + // It should fail for a non-existent script + { + const options = { + threadId: wid, + scriptId: 0, + path: 'non-existent', + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 500, + 'Internal Runtime Error(1007)'); + } + + // It should also fail for a non-existent scriptId + { + const options = { + threadId: wid, + scriptId: 10000, + path: scripts[0].path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 500, + 'Internal Runtime Error(1007)'); + } + + await child.shutdown(0); + grpcServer.close(); + resolve(); + })); + + const env = { + NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', + NSOLID_GRPC_INSECURE: 1, + NSOLID_GRPC: `localhost:${port}`, + }; + + const opts = { + stdio: ['inherit', 'inherit', 'inherit', 'ipc'], + env, + }; + const child = new TestClient([ '-w', 1 ], opts); + const agentId = await child.id(); + const workers = await child.workers(); + const wid = workers[0]; + await child.importURL(importPath, wid); + })); + }); + }, +}); + +tests.push({ + name: 'should also work for imported data urls', + test: async () => { + return new Promise((resolve) => { + const importPath = path.join(fixturesDir, 'nsolid-source-code', 'data.mjs'); + const grpcServer = new GRPCServer(); + grpcServer.start(mustSucceed(async (port) => { + grpcServer.on('loop_blocked', mustCall(async (data) => { + console.dir(data.msg, { depth: null }); + const scripts = []; + for (const frame of data.msg.body.stack) { + if (frame.scriptName.includes(importPath) || + frame.scriptName.startsWith('data:text/javascript,')) { + scripts.push({ + scriptId: frame.scriptId, + path: frame.scriptName, + }); + } + } + + assert.strictEqual(scripts.length, 2); + for (const { scriptId, path } of scripts) { + const options = { + threadId: 0, + scriptId, + path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeData(ret.data.msg, ret.data.metadata, ret.requestId, agentId, options); + } + + await child.shutdown(0); + grpcServer.close(); + resolve(); + })); + + const env = { + NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', + NSOLID_GRPC_INSECURE: 1, + NSOLID_GRPC: `localhost:${port}`, + }; + + const opts = { + stdio: ['inherit', 'inherit', 'inherit', 'ipc'], + env, + }; + const child = new TestClient([], opts); + const agentId = await child.id(); + await child.importURL(importPath, 0); + })); + }); + }, +}); + + +for (const { name, test } of tests) { + console.log(`[source code] ${name}`); + await test(); +} diff --git a/test/common/nsolid-grpc-agent/client.js b/test/common/nsolid-grpc-agent/client.js index 713ce8a67be..5aef9633d6d 100644 --- a/test/common/nsolid-grpc-agent/client.js +++ b/test/common/nsolid-grpc-agent/client.js @@ -78,6 +78,12 @@ function blockFor(duration) { while (Date.now() - start < duration); } +async function handleImport(msg) { + const { url } = msg; + const { blockFor } = await import(url); + blockFor(500); +} + function handleTrace(msg) { if (msg.type === 'trace') { switch (msg.kind) { @@ -111,6 +117,20 @@ if (isMainThread) { nsolid.heapSampling(msg.duration); } else if (msg.type === 'id') { process.send({ type: 'id', id: nsolid.id }); + } else if (msg.type === 'import') { + console.log(msg); + if (threadId === msg.threadId) { + handleImport(msg).then(() => { + process.send(msg); + }); + } else { + const worker = workers.get(msg.threadId); + worker.on('message', (msg) => { + process.send(msg); + }); + + worker.postMessage(msg); + } } else if (msg.type === 'log') { if (threadId === msg.threadId) { nsolid.logger[msg.level](msg.message); @@ -187,6 +207,11 @@ if (isMainThread) { case 'block': blockFor(msg.duration); break; + case 'import': + handleImport(msg).then(() => { + parentPort.postMessage(msg); + }); + break; case 'log': nsolid.logger[msg.level](msg.message); break; diff --git a/test/common/nsolid-grpc-agent/index.js b/test/common/nsolid-grpc-agent/index.js index 7273649c784..eb2abcbc0fd 100644 --- a/test/common/nsolid-grpc-agent/index.js +++ b/test/common/nsolid-grpc-agent/index.js @@ -245,6 +245,22 @@ class GRPCServer extends EventEmitter { }); } + async sourceCode(agentId, options) { + return new Promise((resolve) => { + if (this.#server) { + const requestId = randomUUID(); + this.#server.send({ type: 'source_code', agentId, requestId, options }); + this.#server.on('message', (msg) => { + if (msg.type === 'source_code') { + resolve({ requestId, data: msg.data }); + } + }); + } else { + resolve(null); + } + }); + } + async startupTimes(agentId) { return new Promise((resolve) => { if (this.#server) { @@ -367,6 +383,21 @@ class TestClient { }); } + async importURL(url, threadId) { + return new Promise((resolve) => { + if (this.#child) { + this.#child.send({ type: 'import', url, threadId }); + this.#child.on('message', (msg) => { + if (msg.type === 'import') { + resolve(); + } + }); + } else { + resolve(null); + } + }); + } + async kill(signal) { return new Promise((resolve) => { let done = false; diff --git a/test/common/nsolid-grpc-agent/server.mjs b/test/common/nsolid-grpc-agent/server.mjs index e804509be15..3003128203a 100644 --- a/test/common/nsolid-grpc-agent/server.mjs +++ b/test/common/nsolid-grpc-agent/server.mjs @@ -153,6 +153,13 @@ async function startServer(cb) { console.dir(call.metadata, { depth: null }); callback(null, {}); }, + ExportSourceCode: (call, callback) => { + // Extract data from the request object + console.dir(call.request, { depth: null }); + console.dir(call.metadata, { depth: null }); + callback(null, {}); + process.send({ type: 'source_code', data: { msg: call.request, metadata: call.metadata } }); + }, ExportStartupTimes: (call, callback) => { // Extract data from the request object console.dir(call.request, { depth: null }); @@ -199,6 +206,8 @@ process.on('message', (message) => { sendPackages(message.agentId, message.requestId); } else if (message.type === 'snapshot') { sendHeapSnapshot(message.agentId, message.requestId, message.options); + } else if (message.type === 'source_code') { + sendSourceCode(message.agentId, message.requestId, message.options); } else if (message.type === 'startup_times') { sendStartupTimes(message.agentId, message.requestId); } else if (message.type === 'close') { @@ -273,6 +282,14 @@ async function sendPackages(agentId, requestId) { return sendCommand('packages', agentId, requestId); } +async function sendSourceCode(agentId, requestId, options) { + const args = { + sourceCode: options, + }; + + return sendCommand('source_code', agentId, requestId, args); +} + async function sendStartupTimes(agentId, requestId) { return sendCommand('startup_times', agentId, requestId); } diff --git a/test/fixtures/nsolid-source-code/common.js b/test/fixtures/nsolid-source-code/common.js new file mode 100644 index 00000000000..82095f7bc9d --- /dev/null +++ b/test/fixtures/nsolid-source-code/common.js @@ -0,0 +1,8 @@ +'use strict'; + +function blockFor(duration) { + const start = Date.now(); + while (Date.now() - start < duration); +} + +module.exports = { blockFor }; \ No newline at end of file diff --git a/test/fixtures/nsolid-source-code/data.mjs b/test/fixtures/nsolid-source-code/data.mjs new file mode 100644 index 00000000000..97d046aee71 --- /dev/null +++ b/test/fixtures/nsolid-source-code/data.mjs @@ -0,0 +1,18 @@ +// Define the JavaScript code as a string +const moduleCode = ` +export function blockFor(duration) { + const start = Date.now(); + while (Date.now() - start < duration); +} +`; + +const dataUrl = `data:text/javascript,${moduleCode}`; + +async function blockFor(duration) { + // Dynamically import the module + const module = await import(dataUrl); + // Call the blockFor function from the imported module + module.blockFor(duration); +} + +export { blockFor, moduleCode }; diff --git a/test/fixtures/nsolid-source-code/esm.mjs b/test/fixtures/nsolid-source-code/esm.mjs new file mode 100644 index 00000000000..2e94caca716 --- /dev/null +++ b/test/fixtures/nsolid-source-code/esm.mjs @@ -0,0 +1,7 @@ +import * as common from './common.js'; + +function blockFor(duration) { + return common.blockFor(duration); +} + +export { blockFor }; \ No newline at end of file diff --git a/test/fixtures/nsolid-source-code/index.mjs b/test/fixtures/nsolid-source-code/index.mjs new file mode 100644 index 00000000000..fbcb07fb07d --- /dev/null +++ b/test/fixtures/nsolid-source-code/index.mjs @@ -0,0 +1,7 @@ +import * as esm from './esm.mjs'; + +function blockFor(duration) { + return esm.blockFor(duration); +} + +export { blockFor }; \ No newline at end of file From 44e512d954371a0bd8c32bd0979908b55a14ab14 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Wed, 18 Dec 2024 11:16:50 +0100 Subject: [PATCH 10/19] test: fix flaky nsolid-metrics test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodesource/nsolid/pull/239 Reviewed-By: Juan José Arboleda --- test/addons/nsolid-metrics/binding.cc | 4 ++-- test/addons/nsolid-metrics/nsolid-metrics.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/addons/nsolid-metrics/binding.cc b/test/addons/nsolid-metrics/binding.cc index a4343688e43..2aac0117a1e 100644 --- a/test/addons/nsolid-metrics/binding.cc +++ b/test/addons/nsolid-metrics/binding.cc @@ -44,8 +44,8 @@ static void GetEnvMetricsGone(const FunctionCallbackInfo& args) { assert(args[0]->IsNumber()); uint64_t thread_id = args[0].As()->Value(); SharedThreadMetrics tm = ThreadMetrics::Create(GetEnvInst(thread_id)); - // The cb should never be called as SharedThreadMetrics is destroyed right - // after leaving the current scope. + // The cb should not be called most of the time as SharedThreadMetrics might + // be destroyed right after leaving the current scope. args.GetReturnValue().Set(tm->Update(metrics_cb_gone, nullptr, tm.get())); } diff --git a/test/addons/nsolid-metrics/nsolid-metrics.js b/test/addons/nsolid-metrics/nsolid-metrics.js index a1f32ad66eb..8a57aaab7d9 100644 --- a/test/addons/nsolid-metrics/nsolid-metrics.js +++ b/test/addons/nsolid-metrics/nsolid-metrics.js @@ -25,7 +25,7 @@ if (!isMainThread) { process.on('beforeExit', mustCall(() => { assert.strictEqual(binding.getCbCntr(), wkr_count); - assert.strictEqual(binding.getCbCntrGone(), 0); + assert.ok(binding.getCbCntrGone() < wkr_count/ 2); assert.strictEqual(binding.getCbCntrLambda(), wkr_count); })); From 652a7cd77b592dfaeacb8c97670ab4d6cae34d2a Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Wed, 18 Dec 2024 18:43:34 +0100 Subject: [PATCH 11/19] deps: update opentelemetry-cpp to 1.18.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodesource/nsolid/pull/241 Reviewed-By: Juan José Arboleda --- deps/opentelemetry-cpp/.bazelrc | 3 + .../opentelemetry/common/spin_lock_mutex.h | 6 +- .../opentelemetry/common/string_util.h | 4 +- .../include/opentelemetry/logs/event_logger.h | 5 +- .../api/include/opentelemetry/logs/logger.h | 5 +- .../opentelemetry/logs/logger_type_traits.h | 4 +- .../api/include/opentelemetry/metrics/meter.h | 24 + .../api/include/opentelemetry/metrics/noop.h | 36 + .../opentelemetry/metrics/sync_instruments.h | 77 + .../nostd/internal/absl/README.md | 4 +- .../nostd/internal/absl/base/config.h | 43 +- .../absl/base/internal/inline_variable.h | 10 +- .../internal/absl/base/internal/invoke.h | 10 +- .../nostd/internal/absl/base/macros.h | 8 +- .../nostd/internal/absl/base/options.h | 50 +- .../nostd/internal/absl/meta/type_traits.h | 44 +- .../internal/absl/types/bad_variant_access.h | 14 +- .../internal/absl/types/internal/variant.h | 258 ++-- .../nostd/internal/absl/types/variant.h | 222 +-- .../nostd/internal/absl/utility/utility.h | 68 +- .../api/include/opentelemetry/nostd/variant.h | 11 +- .../opentelemetry/semconv/client_attributes.h | 41 + .../opentelemetry/semconv/error_attributes.h | 57 + .../semconv/exception_attributes.h | 59 + .../opentelemetry/semconv/http_attributes.h | 153 ++ .../opentelemetry/semconv/http_metrics.h | 79 + .../semconv/incubating/artifact_attributes.h | 81 ++ .../semconv/incubating/aws_attributes.h | 356 +++++ .../semconv/incubating/az_attributes.h | 37 + .../semconv/incubating/browser_attributes.h | 65 + .../semconv/incubating/cicd_attributes.h | 76 + .../semconv/incubating/client_attributes.h | 41 + .../semconv/incubating/cloud_attributes.h | 272 ++++ .../incubating/cloudevents_attributes.h | 58 + .../incubating/cloudfoundry_attributes.h | 138 ++ .../semconv/incubating/code_attributes.h | 60 + .../semconv/incubating/container_attributes.h | 157 ++ .../semconv/incubating/container_metrics.h | 224 +++ .../semconv/incubating/cpu_attributes.h | 73 + .../semconv/incubating/db_attributes.h | 841 +++++++++++ .../semconv/incubating/db_metrics.h | 816 +++++++++++ .../incubating/deployment_attributes.h | 76 + .../incubating/destination_attributes.h | 37 + .../semconv/incubating/device_attributes.h | 66 + .../semconv/incubating/disk_attributes.h | 43 + .../semconv/incubating/dns_attributes.h | 34 + .../semconv/incubating/dns_metrics.h | 49 + .../semconv/incubating/enduser_attributes.h | 51 + .../semconv/incubating/error_attributes.h | 57 + .../semconv/incubating/event_attributes.h | 34 + .../semconv/incubating/exception_attributes.h | 59 + .../semconv/incubating/faas_attributes.h | 232 +++ .../semconv/incubating/faas_metrics.h | 287 ++++ .../incubating/feature_flag_attributes.h | 47 + .../semconv/incubating/file_attributes.h | 144 ++ .../semconv/incubating/gcp_attributes.h | 64 + .../semconv/incubating/gen_ai_attributes.h | 263 ++++ .../semconv/incubating/gen_ai_metrics.h | 158 ++ .../semconv/incubating/graphql_attributes.h | 60 + .../semconv/incubating/heroku_attributes.h | 39 + .../semconv/incubating/host_attributes.h | 159 ++ .../semconv/incubating/http_attributes.h | 365 +++++ .../semconv/incubating/http_metrics.h | 353 +++++ .../semconv/incubating/hw_attributes.h | 148 ++ .../semconv/incubating/hw_metrics.h | 174 +++ .../semconv/incubating/k8s_attributes.h | 234 +++ .../semconv/incubating/k8s_metrics.h | 273 ++++ .../semconv/incubating/linux_attributes.h | 43 + .../semconv/incubating/log_attributes.h | 82 ++ .../semconv/incubating/message_attributes.h | 74 + .../semconv/incubating/messaging_attributes.h | 543 +++++++ .../semconv/incubating/messaging_metrics.h | 449 ++++++ .../semconv/incubating/net_attributes.h | 209 +++ .../semconv/incubating/network_attributes.h | 308 ++++ .../semconv/incubating/oci_attributes.h | 36 + .../incubating/opentracing_attributes.h | 45 + .../semconv/incubating/os_attributes.h | 110 ++ .../semconv/incubating/otel_attributes.h | 77 + .../semconv/incubating/other_attributes.h | 47 + .../semconv/incubating/peer_attributes.h | 31 + .../semconv/incubating/pool_attributes.h | 33 + .../semconv/incubating/process_attributes.h | 264 ++++ .../semconv/incubating/process_metrics.h | 454 ++++++ .../semconv/incubating/profile_attributes.h | 81 ++ .../semconv/incubating/rpc_attributes.h | 355 +++++ .../semconv/incubating/rpc_metrics.h | 312 ++++ .../semconv/incubating/server_attributes.h | 41 + .../semconv/incubating/service_attributes.h | 84 ++ .../semconv/incubating/session_attributes.h | 34 + .../semconv/incubating/source_attributes.h | 37 + .../semconv/incubating/system_attributes.h | 383 +++++ .../semconv/incubating/system_metrics.h | 1284 +++++++++++++++++ .../semconv/incubating/telemetry_attributes.h | 125 ++ .../semconv/incubating/test_attributes.h | 93 ++ .../semconv/incubating/thread_attributes.h | 34 + .../semconv/incubating/tls_attributes.h | 221 +++ .../semconv/incubating/url_attributes.h | 137 ++ .../incubating/user_agent_attributes.h | 51 + .../semconv/incubating/user_attributes.h | 57 + .../semconv/incubating/vcs_attributes.h | 86 ++ .../semconv/incubating/webengine_attributes.h | 39 + .../semconv/network_attributes.h | 120 ++ .../opentelemetry/semconv/otel_attributes.h | 59 + .../opentelemetry/semconv/schema_url.h | 24 + .../opentelemetry/semconv/server_attributes.h | 41 + .../semconv/service_attributes.h | 41 + .../semconv/telemetry_attributes.h | 111 ++ .../opentelemetry/semconv/url_attributes.h | 66 + .../semconv/user_agent_attributes.h | 30 + .../opentelemetry/trace/default_span.h | 4 +- .../trace/propagation/http_trace_context.h | 42 +- .../opentelemetry/trace/propagation/jaeger.h | 6 +- .../trace/semantic_conventions.h | 10 +- .../include/opentelemetry/trace/trace_state.h | 3 +- .../api/include/opentelemetry/version.h | 4 +- .../opentelemetry-cpp/api/test/CMakeLists.txt | 5 +- .../api/test/common/spinlock_benchmark.cc | 6 +- .../api/test/common/string_util_test.cc | 8 +- .../api/test/trace/propagation/CMakeLists.txt | 16 +- .../api/test/trace/propagation/detail/BUILD | 16 + .../trace/propagation/detail/CMakeLists.txt | 2 +- .../trace/propagation/detail/string_test.cc | 62 + .../elasticsearch/es_log_recordable.h | 16 +- .../src/es_log_record_exporter.cc | 12 +- .../elasticsearch/src/es_log_recordable.cc | 105 +- .../test/es_log_record_exporter_test.cc | 92 +- .../opentelemetry-cpp/exporters/etw/README.md | 214 +-- .../memory/src/in_memory_metric_data.cc | 7 +- .../src/in_memory_metric_exporter_factory.cc | 7 +- .../memory/test/in_memory_metric_data_test.cc | 8 +- deps/opentelemetry-cpp/exporters/otlp/BUILD | 2 + .../exporters/otlp/CMakeLists.txt | 8 +- .../exporters/otlp/otlp_grpc_client.h | 55 +- .../exporters/otlp/otlp_grpc_client_factory.h | 36 + .../exporters/otlp/otlp_grpc_exporter.h | 40 +- .../otlp/otlp_grpc_exporter_factory.h | 10 + .../otlp/otlp_grpc_log_record_exporter.h | 43 +- .../otlp_grpc_log_record_exporter_factory.h | 12 +- .../otlp/otlp_grpc_metric_exporter.h | 42 +- .../otlp/otlp_grpc_metric_exporter_factory.h | 12 +- .../exporters/otlp/src/otlp_grpc_client.cc | 170 ++- .../otlp/src/otlp_grpc_client_factory.cc | 27 + .../exporters/otlp/src/otlp_grpc_exporter.cc | 108 +- .../otlp/src/otlp_grpc_exporter_factory.cc | 9 + .../otlp/src/otlp_grpc_log_record_exporter.cc | 113 +- .../otlp_grpc_log_record_exporter_factory.cc | 9 + .../otlp/src/otlp_grpc_metric_exporter.cc | 110 +- .../src/otlp_grpc_metric_exporter_factory.cc | 9 + .../exporters/otlp/src/otlp_http_client.cc | 1 + .../exporters/otlp/src/otlp_metric_utils.cc | 2 + .../test/otlp_grpc_exporter_factory_test.cc | 22 + ...p_grpc_log_record_exporter_factory_test.cc | 24 + .../otlp_grpc_log_record_exporter_test.cc | 132 ++ .../otlp_grpc_metric_exporter_factory_test.cc | 24 + .../otlp/test/otlp_log_recordable_test.cc | 1 - .../exporters/prometheus/exporter_options.h | 6 + .../exporters/prometheus/exporter_utils.h | 12 +- .../prometheus/src/exporter_options.cc | 25 +- .../prometheus/src/exporter_utils.cc | 67 +- .../prometheus/test/exporter_utils_test.cc | 94 +- .../exporters/zipkin/src/recordable.cc | 6 +- .../ext/http/client/curl/http_client_curl.h | 3 + .../http/client/curl/http_operation_curl.h | 11 +- .../ext/http/client/http_client.h | 2 + .../ext/http/common/url_parser.h | 92 +- .../ext/http/server/http_server.h | 10 +- .../ext/src/http/client/curl/CMakeLists.txt | 5 + .../src/http/client/curl/http_client_curl.cc | 10 +- .../http/client/curl/http_operation_curl.cc | 91 +- .../opentelemetry-cpp/ext/test/CMakeLists.txt | 2 +- .../ext/test/http/CMakeLists.txt | 6 +- .../ext/test/http/url_parser_test.cc | 312 ++-- .../BUILD | 2 +- .../CMakeLists.txt | 7 +- .../Dockerfile | 0 .../README.md | 13 +- .../main.cc | 52 +- deps/opentelemetry-cpp/otlp-http-exporter.gyp | 1 + .../sdk/common/empty_attributes.h | 6 +- .../metrics/aggregation/default_aggregation.h | 1 + .../opentelemetry/sdk/metrics/instruments.h | 1 + .../include/opentelemetry/sdk/metrics/meter.h | 12 + .../sdk/metrics/sync_instruments.h | 34 + .../sdk/resource/semantic_conventions.h | 10 +- .../opentelemetry/sdk/trace/span_data.h | 2 +- .../opentelemetry/sdk/version/version.h | 2 +- .../sdk/src/common/CMakeLists.txt | 2 +- deps/opentelemetry-cpp/sdk/src/logs/BUILD | 1 - deps/opentelemetry-cpp/sdk/src/metrics/BUILD | 1 - .../sdk/src/metrics/meter.cc | 44 + .../sdk/src/metrics/state/metric_collector.cc | 13 +- .../sdk/src/metrics/sync_instruments.cc | 121 ++ deps/opentelemetry-cpp/sdk/src/resource/BUILD | 1 - .../sdk/src/resource/resource.cc | 16 +- .../sdk/src/resource/resource_detector.cc | 4 +- .../sdk/src/version/version.cc | 8 +- .../sdk/test/metrics/CMakeLists.txt | 1 + .../sdk/test/metrics/sync_instruments_test.cc | 39 + .../metrics/sync_metric_storage_gauge_test.cc | 189 +++ .../sdk/test/resource/resource_test.cc | 30 +- .../profiles_service.proto | 12 +- .../profiles_service_http.yaml | 4 +- .../proto/metrics/v1/metrics.proto | 27 +- .../profiles.proto} | 327 +++-- .../profiles/v1experimental/profiles.proto | 191 --- deps/opentelemetry-cpp/third_party_release | 4 +- 206 files changed, 16890 insertions(+), 1555 deletions(-) create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/client_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/error_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/exception_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/http_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/http_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/artifact_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/aws_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/az_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/browser_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cicd_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/client_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloud_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/code_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cpu_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/deployment_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/destination_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/device_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/disk_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/dns_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/dns_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/enduser_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/error_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/event_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/exception_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/file_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gcp_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/graphql_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/heroku_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/host_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/http_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/http_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/linux_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/log_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/message_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/net_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/network_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/oci_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/opentracing_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/os_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/other_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/peer_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/pool_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/profile_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/server_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/service_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/session_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/source_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_metrics.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/test_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/thread_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/tls_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/url_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/user_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/webengine_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/network_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/otel_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/schema_url.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/server_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/service_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/url_attributes.h create mode 100644 deps/opentelemetry-cpp/api/include/opentelemetry/semconv/user_agent_attributes.h create mode 100644 deps/opentelemetry-cpp/api/test/trace/propagation/detail/string_test.cc create mode 100644 deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h create mode 100644 deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client_factory.cc rename deps/opentelemetry-cpp/ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/BUILD (92%) rename deps/opentelemetry-cpp/ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/CMakeLists.txt (66%) rename deps/opentelemetry-cpp/ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/Dockerfile (100%) rename deps/opentelemetry-cpp/ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/README.md (80%) rename deps/opentelemetry-cpp/ext/test/{w3c_tracecontext_test => w3c_tracecontext_http_test_server}/main.cc (86%) create mode 100644 deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_gauge_test.cc rename deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/{v1experimental => v1development}/profiles_service.proto (91%) rename deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/{v1experimental => v1development}/profiles_service_http.yaml (63%) rename deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/{v1experimental/pprofextended.proto => v1development/profiles.proto} (56%) delete mode 100644 deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/profiles.proto diff --git a/deps/opentelemetry-cpp/.bazelrc b/deps/opentelemetry-cpp/.bazelrc index f1693476474..57cd0a2fa0c 100644 --- a/deps/opentelemetry-cpp/.bazelrc +++ b/deps/opentelemetry-cpp/.bazelrc @@ -7,6 +7,9 @@ # Enable automatic configs based on platform common --enable_platform_specific_config +# Make globs that don't match anything fail +common --incompatible_disallow_empty_glob + # Needed by gRPC to build on some platforms. build --copt -DGRPC_BAZEL_BUILD diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/common/spin_lock_mutex.h b/deps/opentelemetry-cpp/api/include/opentelemetry/common/spin_lock_mutex.h index 369183b953b..7031fa4d23f 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/common/spin_lock_mutex.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/common/spin_lock_mutex.h @@ -68,8 +68,10 @@ class SpinLockMutex # else __builtin_ia32_pause(); # endif -#elif defined(__arm__) - __asm__ volatile("yield" ::: "memory"); +#elif defined(__armel__) || defined(__ARMEL__) + asm volatile("nop" ::: "memory"); +#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64 + __asm__ __volatile__("yield" ::: "memory"); #else // TODO: Issue PAGE/YIELD on other architectures. #endif diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h b/deps/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h index a7070a0acde..273a65272ba 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h @@ -15,11 +15,11 @@ class StringUtil public: static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept { - while (left <= right && str[static_cast(left)] == ' ') + while (left <= right && isspace(str[left])) { left++; } - while (left <= right && str[static_cast(right)] == ' ') + while (left <= right && isspace(str[right])) { right--; } diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/event_logger.h b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/event_logger.h index b5c94a7067f..d3049953bc3 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/event_logger.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/event_logger.h @@ -65,9 +65,8 @@ class EventLogger } nostd::unique_ptr log_record = delegate_logger->CreateLogRecord(); - IgnoreTraitResult( - detail::LogRecordSetterTrait::type>::template Set( - log_record.get(), std::forward(args))...); + IgnoreTraitResult(detail::LogRecordSetterTrait::type>::Set( + log_record.get(), std::forward(args))...); EmitEvent(event_name, std::move(log_record)); } diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/logger.h b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/logger.h index dc09a0c2b47..519516f2979 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/logger.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/logger.h @@ -72,9 +72,8 @@ class Logger return; } - IgnoreTraitResult( - detail::LogRecordSetterTrait::type>::template Set( - log_record.get(), std::forward(args))...); + IgnoreTraitResult(detail::LogRecordSetterTrait::type>::Set( + log_record.get(), std::forward(args))...); EmitLogRecord(std::move(log_record)); } diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/logger_type_traits.h b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/logger_type_traits.h index 486135137d5..d88a6ffbdc6 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/logger_type_traits.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/logger_type_traits.h @@ -166,8 +166,8 @@ struct LogRecordSetterTrait * = nullptr> inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { - return LogRecordSetterTrait::template Set( - log_record, std::forward(arg)); + return LogRecordSetterTrait::Set(log_record, + std::forward(arg)); } template class UpDownCounter; +template +class Gauge; + class ObservableInstrument; /** @@ -91,6 +94,27 @@ class Meter nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + /** + * Creates a Gauge with the passed characteristics and returns a unique_ptr to that Gauge. + * + * @param name the name of the new Gauge. + * @param description a brief description of what the Gauge is used for. + * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. + * @return a unique pointer to the created Gauge. + */ + + virtual nostd::unique_ptr> CreateInt64Gauge( + nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept = 0; + + virtual nostd::unique_ptr> CreateDoubleGauge( + nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept = 0; +#endif + /** * Creates a Asynchronous (Observable) Gauge with the passed characteristics and returns a * shared_ptr to that Observable Gauge diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/metrics/noop.h b/deps/opentelemetry-cpp/api/include/opentelemetry/metrics/noop.h index d34a0e681b6..1d508b93877 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/metrics/noop.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/metrics/noop.h @@ -71,6 +71,26 @@ class NoopUpDownCounter : public UpDownCounter {} }; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +template +class NoopGauge : public Gauge +{ +public: + NoopGauge(nostd::string_view /* name */, + nostd::string_view /* description */, + nostd::string_view /* unit */) noexcept + {} + ~NoopGauge() override = default; + void Record(T /* value */) noexcept override {} + void Record(T /* value */, const context::Context & /* context */) noexcept override {} + void Record(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {} + void Record(T /* value */, + const common::KeyValueIterable & /* attributes */, + const context::Context & /* context */) noexcept override + {} +}; +#endif + class NoopObservableInstrument : public ObservableInstrument { public: @@ -140,6 +160,22 @@ class NoopMeter final : public Meter return nostd::unique_ptr>{new NoopHistogram(name, description, unit)}; } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::unique_ptr> CreateInt64Gauge(nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept override + { + return nostd::unique_ptr>{new NoopGauge(name, description, unit)}; + } + + nostd::unique_ptr> CreateDoubleGauge(nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept override + { + return nostd::unique_ptr>{new NoopGauge(name, description, unit)}; + } +#endif + nostd::shared_ptr CreateInt64ObservableGauge( nostd::string_view name, nostd::string_view description = "", diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/metrics/sync_instruments.h b/deps/opentelemetry-cpp/api/include/opentelemetry/metrics/sync_instruments.h index 44716774338..9eaec3352f2 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/metrics/sync_instruments.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/metrics/sync_instruments.h @@ -247,5 +247,82 @@ class UpDownCounter : public SynchronousInstrument } }; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +/* A Gauge instrument that records values. */ +template +class Gauge : public SynchronousInstrument +{ + +public: + /** + * Record a value + * + * @param value The measurement value. May be positive, negative or zero. + */ + virtual void Record(T value) noexcept = 0; + + /** + * Record a value + * + * @param value The measurement value. May be positive, negative or zero. + * @param context The explicit context to associate with this measurement. + */ + virtual void Record(T value, const context::Context &context) noexcept = 0; + + /** + * Record a value with a set of attributes. + * + * @param value The measurement value. May be positive, negative or zero. + * @param attributes A set of attributes to associate with the value. + */ + + virtual void Record(T value, const common::KeyValueIterable &attributes) noexcept = 0; + + /** + * Record a value with a set of attributes. + * + * @param value The measurement value. May be positive, negative or zero. + * @param attributes A set of attributes to associate with the value. + * @param context The explicit context to associate with this measurement. + */ + virtual void Record(T value, + const common::KeyValueIterable &attributes, + const context::Context &context) noexcept = 0; + + template ::value> * = nullptr> + void Record(T value, const U &attributes) noexcept + { + this->Record(value, common::KeyValueIterableView{attributes}); + } + + template ::value> * = nullptr> + void Record(T value, const U &attributes, const context::Context &context) noexcept + { + this->Record(value, common::KeyValueIterableView{attributes}, context); + } + + void Record(T value, + std::initializer_list> + attributes) noexcept + { + this->Record(value, nostd::span>{ + attributes.begin(), attributes.end()}); + } + + void Record( + T value, + std::initializer_list> attributes, + const context::Context &context) noexcept + { + this->Record(value, + nostd::span>{ + attributes.begin(), attributes.end()}, + context); + } +}; +#endif + } // namespace metrics OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/README.md b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/README.md index 6a408557046..5dd661971f5 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/README.md +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/README.md @@ -1,4 +1,4 @@ # Notes on Abseil Variant implementation -This is a snapshot of Abseil Variant `absl::variant` from Abseil -`v2020-03-03#8`. +This is a snapshot of Abseil Variant +`absl::OTABSL_OPTION_NAMESPACE_NAME::variant` from Abseil `v2020-03-03#8`. diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/config.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/config.h index 3f78df3d985..e0836b9b3f9 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/config.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/config.h @@ -84,7 +84,7 @@ // namespace absl { // OTABSL_NAMESPACE_BEGIN // -// void Foo(); // absl::Foo(). +// void Foo(); // absl::OTABSL_OPTION_NAMESPACE_NAME::Foo(). // // OTABSL_NAMESPACE_END // } // namespace absl @@ -94,40 +94,32 @@ // not support forward declarations of its own types, nor does it support // user-provided specialization of Abseil templates. Code that violates these // rules may be broken without warning.) -#if !defined(OTABSL_OPTION_USE_INLINE_NAMESPACE) || \ - !defined(OTABSL_OPTION_INLINE_NAMESPACE_NAME) +#if !defined(OTABSL_OPTION_NAMESPACE_NAME) #error options.h is misconfigured. #endif -// Check that OTABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor "" -#if defined(__cplusplus) && OTABSL_OPTION_USE_INLINE_NAMESPACE == 1 +// Check that OTABSL_OPTION_NAMESPACE_NAME is neither "head" nor "" +#if defined(__cplusplus) #define OTABSL_INTERNAL_INLINE_NAMESPACE_STR \ - OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_INLINE_NAMESPACE_NAME) + OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', - "options.h misconfigured: OTABSL_OPTION_INLINE_NAMESPACE_NAME must " + "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must " "not be empty."); static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', - "options.h misconfigured: OTABSL_OPTION_INLINE_NAMESPACE_NAME must " + "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must " "be changed to a new, unique identifier name."); #endif -#if OTABSL_OPTION_USE_INLINE_NAMESPACE == 0 -#define OTABSL_NAMESPACE_BEGIN -#define OTABSL_NAMESPACE_END -#elif OTABSL_OPTION_USE_INLINE_NAMESPACE == 1 -#define OTABSL_NAMESPACE_BEGIN \ - inline namespace OTABSL_OPTION_INLINE_NAMESPACE_NAME { + +#define OTABSL_NAMESPACE_BEGIN namespace OTABSL_OPTION_NAMESPACE_NAME { #define OTABSL_NAMESPACE_END } -#else -#error options.h is misconfigured. -#endif // ----------------------------------------------------------------------------- // Compiler Feature Checks @@ -217,7 +209,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_HAVE_SOURCE_LOCATION_CURRENT // -// Indicates whether `absl::SourceLocation::current()` will return useful +// Indicates whether `absl::OTABSL_OPTION_NAMESPACE_NAME::SourceLocation::current()` will return useful // information in some contexts. #ifndef OTABSL_HAVE_SOURCE_LOCATION_CURRENT #if OTABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \ @@ -570,7 +562,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_USES_STD_ANY // -// Indicates whether absl::any is an alias for std::any. +// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is an alias for std::any. #if !defined(OTABSL_OPTION_USE_STD_ANY) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_ANY == 0 || \ @@ -585,7 +577,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_USES_STD_OPTIONAL // -// Indicates whether absl::optional is an alias for std::optional. +// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is an alias for std::optional. #if !defined(OTABSL_OPTION_USE_STD_OPTIONAL) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_OPTIONAL == 0 || \ @@ -600,7 +592,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_USES_STD_VARIANT // -// Indicates whether absl::variant is an alias for std::variant. +// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is an alias for std::variant. #if !defined(OTABSL_OPTION_USE_STD_VARIANT) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_VARIANT == 0 || \ @@ -615,7 +607,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // OTABSL_USES_STD_STRING_VIEW // -// Indicates whether absl::string_view is an alias for std::string_view. +// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is an alias for std::string_view. #if !defined(OTABSL_OPTION_USE_STD_STRING_VIEW) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_STRING_VIEW == 0 || \ @@ -650,15 +642,10 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // the proper count to skip past the CCTZ fork namespace names. (This number // is one larger when there is an inline namespace name to skip.) #if defined(_MSC_VER) -#if OTABSL_OPTION_USE_INLINE_NAMESPACE == 0 -#define OTABSL_INTERNAL_MANGLED_NS "absl" -#define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "5" -#else #define OTABSL_INTERNAL_MANGLED_NS \ - OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_INLINE_NAMESPACE_NAME) "@absl" + OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) "@absl" #define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "6" #endif -#endif #undef OTABSL_INTERNAL_HAS_KEYWORD diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h index 9d024a2d91e..dd66e9f223f 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h @@ -68,7 +68,7 @@ // types, etc.. #if defined(__clang__) #define OTABSL_INTERNAL_EXTERN_DECL(type, name) \ - extern const ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t name; + extern const ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t name; #else // Otherwise, just define the macro to do nothing. #define OTABSL_INTERNAL_EXTERN_DECL(type, name) #endif // defined(__clang__) @@ -76,7 +76,7 @@ // See above comment at top of file for details. #define OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \ OTABSL_INTERNAL_EXTERN_DECL(type, name) \ - inline constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t name = init + inline constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t name = init #else @@ -89,14 +89,14 @@ #define OTABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \ template \ struct AbslInternalInlineVariableHolder##name { \ - static constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t kInstance = init; \ + static constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t kInstance = init; \ }; \ \ template \ - constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t \ + constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t \ AbslInternalInlineVariableHolder##name::kInstance; \ \ - static constexpr const ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t& \ + static constexpr const ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t& \ name = /* NOLINT */ \ AbslInternalInlineVariableHolder##name<>::kInstance; \ static_assert(sizeof(void (*)(decltype(name))) != 0, \ diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h index 99c37ba24ad..c37f43cfc89 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// absl::base_internal::Invoke(f, args...) is an implementation of +// absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke(f, args...) is an implementation of // INVOKE(f, args...) from section [func.require] of the C++ standard. // // [func.require] @@ -73,7 +73,7 @@ struct MemFunAndRef : StrippedAccept { template struct AcceptImpl : std::integral_constant::value && - absl::is_function::value> { + absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> { }; template @@ -94,7 +94,7 @@ struct MemFunAndPtr : StrippedAccept { template struct AcceptImpl : std::integral_constant::value && - absl::is_function::value> { + absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> { }; template @@ -116,7 +116,7 @@ struct DataMemAndRef : StrippedAccept { template struct AcceptImpl : std::integral_constant::value && - !absl::is_function::value> {}; + !absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> {}; template static decltype(std::declval().*std::declval()) Invoke( @@ -134,7 +134,7 @@ struct DataMemAndPtr : StrippedAccept { template struct AcceptImpl : std::integral_constant::value && - !absl::is_function::value> {}; + !absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> {}; template static decltype((*std::declval()).*std::declval()) Invoke( diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/macros.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/macros.h index 7b4f427d30f..707c375ed10 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/macros.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/macros.h @@ -41,7 +41,7 @@ // can be used in defining new arrays. If you use this macro on a pointer by // mistake, you will get a compile-time error. #define OTABSL_ARRAYSIZE(array) \ - (sizeof(::absl::macros_internal::ArraySizeHelper(array))) + (sizeof(::absl::OTABSL_OPTION_NAMESPACE_NAME::macros_internal::ArraySizeHelper(array))) namespace absl { OTABSL_NAMESPACE_BEGIN @@ -60,7 +60,7 @@ OTABSL_NAMESPACE_END // static storage duration, and that the constructor should do nothing to its // state. Use of this macro indicates to the reader that it is legal to // declare a static instance of the class, provided the constructor is given -// the absl::base_internal::kLinkerInitialized argument. +// the absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::kLinkerInitialized argument. // // Normally, it is unsafe to declare a static variable that has a constructor or // a destructor because invocation order is undefined. However, if the type can @@ -70,10 +70,10 @@ OTABSL_NAMESPACE_END // // Example: // // Declaration -// explicit MyClass(absl::base_internal:LinkerInitialized x) {} +// explicit MyClass(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal:LinkerInitialized x) {} // // // Invocation -// static MyClass my_global(absl::base_internal::kLinkerInitialized); +// static MyClass my_global(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::kLinkerInitialized); namespace absl { OTABSL_NAMESPACE_BEGIN namespace base_internal { diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/options.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/options.h index 3632b74f64a..26665b151e8 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/options.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/base/options.h @@ -79,7 +79,7 @@ // // OTABSL_OPTION_USE_STD_ANY // -// This option controls whether absl::any is implemented as an alias to +// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is implemented as an alias to // std::any, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 @@ -93,19 +93,19 @@ // useful when you are building your entire program, including all of its // dependencies, from source. It should not be used otherwise -- for example, // if you are distributing Abseil in a binary package manager -- since in -// mode 2, absl::any will name a different type, with a different mangled name +// mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::any will name a different type, with a different mangled name // and binary layout, depending on the compiler flags passed by the end user. // For more info, see https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if -// absl::any is a typedef of std::any, use the feature macro OTABSL_USES_STD_ANY. +// absl::OTABSL_OPTION_NAMESPACE_NAME::any is a typedef of std::any, use the feature macro OTABSL_USES_STD_ANY. #define OTABSL_OPTION_USE_STD_ANY 0 // OTABSL_OPTION_USE_STD_OPTIONAL // -// This option controls whether absl::optional is implemented as an alias to +// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is implemented as an alias to // std::optional, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 @@ -118,13 +118,13 @@ // and use an alias only if a working std::optional is available. This option // is useful when you are building your program from source. It should not be // used otherwise -- for example, if you are distributing Abseil in a binary -// package manager -- since in mode 2, absl::optional will name a different +// package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::optional will name a different // type, with a different mangled name and binary layout, depending on the // compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // User code should not inspect this macro. To check in the preprocessor if -// absl::optional is a typedef of std::optional, use the feature macro +// absl::OTABSL_OPTION_NAMESPACE_NAME::optional is a typedef of std::optional, use the feature macro // OTABSL_USES_STD_OPTIONAL. #define OTABSL_OPTION_USE_STD_OPTIONAL 0 @@ -132,7 +132,7 @@ // OTABSL_OPTION_USE_STD_STRING_VIEW // -// This option controls whether absl::string_view is implemented as an alias to +// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is implemented as an alias to // std::string_view, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 @@ -145,20 +145,20 @@ // and use an alias only if a working std::string_view is available. This // option is useful when you are building your program from source. It should // not be used otherwise -- for example, if you are distributing Abseil in a -// binary package manager -- since in mode 2, absl::string_view will name a +// binary package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::string_view will name a // different type, with a different mangled name and binary layout, depending on // the compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if -// absl::string_view is a typedef of std::string_view, use the feature macro +// absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is a typedef of std::string_view, use the feature macro // OTABSL_USES_STD_STRING_VIEW. #define OTABSL_OPTION_USE_STD_STRING_VIEW 0 // OTABSL_OPTION_USE_STD_VARIANT // -// This option controls whether absl::variant is implemented as an alias to +// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is implemented as an alias to // std::variant, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 @@ -171,41 +171,23 @@ // and use an alias only if a working std::variant is available. This option // is useful when you are building your program from source. It should not be // used otherwise -- for example, if you are distributing Abseil in a binary -// package manager -- since in mode 2, absl::variant will name a different +// package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::variant will name a different // type, with a different mangled name and binary layout, depending on the // compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if -// absl::variant is a typedef of std::variant, use the feature macro +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant is a typedef of std::variant, use the feature macro // OTABSL_USES_STD_VARIANT. #define OTABSL_OPTION_USE_STD_VARIANT 0 -// OTABSL_OPTION_USE_INLINE_NAMESPACE -// OTABSL_OPTION_INLINE_NAMESPACE_NAME +// OTABSL_OPTION_NAMESPACE_NAME // -// These options controls whether all entities in the absl namespace are -// contained within an inner inline namespace. This does not affect the -// user-visible API of Abseil, but it changes the mangled names of all symbols. -// -// This can be useful as a version tag if you are distributing Abseil in -// precompiled form. This will prevent a binary library build of Abseil with -// one inline namespace being used with headers configured with a different -// inline namespace name. Binary packagers are reminded that Abseil does not -// guarantee any ABI stability in Abseil, so any update of Abseil or -// configuration change in such a binary package should be combined with a -// new, unique value for the inline namespace name. -// -// A value of 0 means not to use inline namespaces. -// -// A value of 1 means to use an inline namespace with the given name inside -// namespace absl. If this is set, OTABSL_OPTION_INLINE_NAMESPACE_NAME must also -// be changed to a new, unique identifier name. In particular "head" is not -// allowed. +// All codes in otabsl are under OTABSL_OPTION_NAMESPACE_NAME, we do not use inline namespace to avoid +// conlict with external Abseil. -#define OTABSL_OPTION_USE_INLINE_NAMESPACE 1 -#define OTABSL_OPTION_INLINE_NAMESPACE_NAME otel_v1 +#define OTABSL_OPTION_NAMESPACE_NAME otel_v1 #endif // OTABSL_BASE_OPTIONS_H_ diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h index 00c90f82d15..dbd03488714 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h @@ -81,43 +81,31 @@ struct IsTriviallyMoveConstructibleObject : std::integral_constant< bool, std::is_move_constructible< type_traits_internal::SingleMemberUnion>::value && - absl::is_trivially_destructible::value> {}; + absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible::value> {}; template struct IsTriviallyCopyConstructibleObject : std::integral_constant< bool, std::is_copy_constructible< type_traits_internal::SingleMemberUnion>::value && - absl::is_trivially_destructible::value> {}; + absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible::value> {}; template struct IsTriviallyMoveAssignableReference : std::false_type {}; template struct IsTriviallyMoveAssignableReference - : absl::is_trivially_move_assignable::type {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable::type {}; template struct IsTriviallyMoveAssignableReference - : absl::is_trivially_move_assignable::type {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable::type {}; template struct VoidTImpl { using type = void; }; -// This trick to retrieve a default alignment is necessary for our -// implementation of aligned_storage_t to be consistent with any implementation -// of std::aligned_storage. -template > -struct default_alignment_of_aligned_storage; - -template -struct default_alignment_of_aligned_storage> { - static constexpr size_t value = Align; -}; - //////////////////////////////// // Library Fundamentals V2 TS // //////////////////////////////// @@ -203,7 +191,7 @@ struct is_move_assignable : type_traits_internal::is_detected< // This metafunction is designed to be a drop-in replacement for the C++17 // `std::void_t` metafunction. // -// NOTE: `absl::void_t` does not use the standard-specified implementation so +// NOTE: `absl::OTABSL_OPTION_NAMESPACE_NAME::void_t` does not use the standard-specified implementation so // that it can remain compatible with gcc < 5.1. This can introduce slightly // different behavior, such as when ordering partial specializations. template @@ -505,7 +493,7 @@ struct is_trivially_copy_assignable #else : std::integral_constant< bool, __has_trivial_assign(typename std::remove_reference::type) && - absl::is_copy_assignable::value> { + absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable::value> { #endif #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE private: @@ -549,8 +537,8 @@ class is_trivially_copyable_impl { std::is_copy_constructible::value || std::is_move_constructible::value; static constexpr bool kIsCopyOrMoveAssignable = - absl::is_copy_assignable::value || - absl::is_move_assignable::value; + absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable::value || + absl::OTABSL_OPTION_NAMESPACE_NAME::is_move_assignable::value; public: static constexpr bool kValue = @@ -619,10 +607,6 @@ using remove_extent_t = typename std::remove_extent::type; template using remove_all_extents_t = typename std::remove_all_extents::type; -template ::value> -using aligned_storage_t = typename std::aligned_storage::type; - template using decay_t = typename std::decay::type; @@ -677,7 +661,7 @@ struct IsHashable : std::false_type {}; template struct IsHashable< Key, - absl::enable_if_t&>()(std::declval())), std::size_t>::value>> : std::true_type {}; #endif // !OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ @@ -703,7 +687,7 @@ struct AssertHashEnabledHelper { static_assert( std::is_copy_constructible>::value, "std::hash must be copy constructible when it is enabled"); - static_assert(absl::is_copy_assignable>::value, + static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable>::value, "std::hash must be copy assignable when it is enabled"); // is_destructible is unchecked as it's implied by each of the // is_constructible checks. @@ -733,7 +717,7 @@ namespace swap_internal { // Necessary for the traits. using std::swap; -// This declaration prevents global `swap` and `absl::swap` overloads from being +// This declaration prevents global `swap` and `absl::OTABSL_OPTION_NAMESPACE_NAME::swap` overloads from being // considered unless ADL picks them up. void swap(); @@ -752,7 +736,7 @@ using IsNothrowSwappableImpl = typename std::enable_if::type; // arguments of type `T`. template struct IsSwappable - : absl::type_traits_internal::is_detected {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::type_traits_internal::is_detected {}; // IsNothrowSwappable // @@ -760,13 +744,13 @@ struct IsSwappable // arguments of type `T` and is noexcept. template struct IsNothrowSwappable - : absl::type_traits_internal::is_detected {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::type_traits_internal::is_detected {}; // Swap() // // Performs the swap idiom from a namespace where valid candidates may only be // found in `std` or via ADL. -template ::value, int> = 0> +template ::value, int> = 0> void Swap(T& lhs, T& rhs) noexcept(IsNothrowSwappable::value) { swap(lhs, rhs); } diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h index 81caa0d75c2..89fe750dbd0 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h @@ -16,7 +16,7 @@ // bad_variant_access.h // ----------------------------------------------------------------------------- // -// This header file defines the `absl::bad_variant_access` type. +// This header file defines the `absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access` type. #ifndef OTABSL_TYPES_BAD_VARIANT_ACCESS_H_ #define OTABSL_TYPES_BAD_VARIANT_ACCESS_H_ @@ -44,21 +44,21 @@ OTABSL_NAMESPACE_BEGIN // bad_variant_access // ----------------------------------------------------------------------------- // -// An `absl::bad_variant_access` type is an exception type that is thrown in +// An `absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access` type is an exception type that is thrown in // the following cases: // -// * Calling `absl::get(absl::variant) with an index or type that does not +// * Calling `absl::OTABSL_OPTION_NAMESPACE_NAME::get(absl::OTABSL_OPTION_NAMESPACE_NAME::variant) with an index or type that does not // match the currently selected alternative type -// * Calling `absl::visit on an `absl::variant` that is in the +// * Calling `absl::OTABSL_OPTION_NAMESPACE_NAME::visit on an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` that is in the // `variant::valueless_by_exception` state. // // Example: // -// absl::variant v; +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant v; // v = 1; // try { -// absl::get(v); -// } catch(const absl::bad_variant_access& e) { +// absl::OTABSL_OPTION_NAMESPACE_NAME::get(v); +// } catch(const absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access& e) { // std::cout << "Bad variant access: " << e.what() << '\n'; // } class bad_variant_access : public std::exception { diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h index ee42da7c930..fc73cf5328b 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h @@ -136,24 +136,24 @@ struct VariantAccessResultImpl; template class Variantemplate, class... T> struct VariantAccessResultImpl&> { - using type = typename absl::variant_alternative>::type&; + using type = typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type&; }; template class Variantemplate, class... T> struct VariantAccessResultImpl&> { using type = - const typename absl::variant_alternative>::type&; + const typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type&; }; template class Variantemplate, class... T> struct VariantAccessResultImpl&&> { - using type = typename absl::variant_alternative>::type&&; + using type = typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type&&; }; template class Variantemplate, class... T> struct VariantAccessResultImpl&&> { using type = - const typename absl::variant_alternative>::type&&; + const typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type&&; }; template @@ -198,7 +198,7 @@ using AlwaysZero = SizeT<0>; template struct VisitIndicesResultImpl { - using type = absl::result_of_t...)>; + using type = absl::OTABSL_OPTION_NAMESPACE_NAME::result_of_t...)>; }; template @@ -214,7 +214,7 @@ constexpr ReturnType call_with_indices(FunctionObject&& function) { std::is_same()( SizeT()...))>::value, "Not all visitation overloads have the same return type."); - return absl::forward(function)(SizeT()...); + return absl::OTABSL_OPTION_NAMESPACE_NAME::forward(function)(SizeT()...); } template @@ -265,7 +265,7 @@ struct MakeVisitationMatrix> : MakeVisitationMatrixImpl, - absl::make_index_sequence, + absl::OTABSL_OPTION_NAMESPACE_NAME::make_index_sequence, index_sequence> {}; struct UnreachableSwitchCase { @@ -284,7 +284,7 @@ struct UnreachableSwitchCase { assert(false); // NOLINT // Hack to silence potential no return warning -- cause an infinite loop. - return Run(absl::forward(op)); + return Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); #endif // Checks for __builtin_unreachable } }; @@ -292,7 +292,7 @@ struct UnreachableSwitchCase { template struct ReachableSwitchCase { static VisitIndicesResultT Run(Op&& op) { - return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke(absl::forward(op), SizeT()); + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op), SizeT()); } }; @@ -326,7 +326,7 @@ using PickCase = typename PickCaseImpl<(I < EndIndex)>::template Apply; template [[noreturn]] ReturnType TypedThrowBadVariantAccess() { - absl::variant_internal::ThrowBadVariantAccess(); + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_internal::ThrowBadVariantAccess(); } // Given N variant sizes, determine the number of cases there would need to be @@ -357,74 +357,74 @@ struct VisitIndicesSwitch { static VisitIndicesResultT Run(Op&& op, std::size_t i) { switch (i) { case 0: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 1: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 2: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 3: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 4: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 5: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 6: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 7: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 8: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 9: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 10: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 11: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 12: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 13: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 14: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 15: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 16: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 17: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 18: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 19: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 20: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 21: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 22: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 23: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 24: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 25: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 26: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 27: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 28: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 29: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 30: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 31: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); case 32: - return PickCase::Run(absl::forward(op)); + return PickCase::Run(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); default: OTABSL_ASSERT(i == variant_npos); - return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke(absl::forward(op), NPos()); + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op), NPos()); } } }; @@ -437,7 +437,7 @@ struct VisitIndicesFallback { MakeVisitationMatrix, Op, index_sequence<(EndIndices + 1)...>, index_sequence<>>::Run(), - (indices + 1)...)(absl::forward(op)); + (indices + 1)...)(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)); } }; @@ -479,7 +479,7 @@ template struct VisitIndicesVariadicImpl; template -struct VisitIndicesVariadicImpl, EndIndices...> { +struct VisitIndicesVariadicImpl, EndIndices...> { // A type that can take an N-ary function object and converts it to a unary // function object that takes a single, flattened index, and "unflattens" it // into its individual dimensions when forwarding to the wrapped object. @@ -488,8 +488,8 @@ struct VisitIndicesVariadicImpl, EndIndices...> { template VisitIndicesResultT operator()( SizeT /*index*/) && { - return OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( - absl::forward(op), + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke( + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op), SizeT::value - std::size_t{1}>()...); } @@ -501,7 +501,7 @@ struct VisitIndicesVariadicImpl, EndIndices...> { static VisitIndicesResultT Run( Op&& op, SizeType... i) { return VisitIndicesSwitch::value>::Run( - FlattenedOp{absl::forward(op)}, + FlattenedOp{absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op)}, FlattenIndices<(EndIndices + std::size_t{1})...>::Run( (i + std::size_t{1})...)); } @@ -509,7 +509,7 @@ struct VisitIndicesVariadicImpl, EndIndices...> { template struct VisitIndicesVariadic - : VisitIndicesVariadicImpl, + : VisitIndicesVariadicImpl, EndIndices...> {}; // This implementation will flatten N-ary visit operations into a single switch @@ -522,14 +522,14 @@ struct VisitIndicesVariadic // size. template struct VisitIndices - : absl::conditional_t<(NumCasesOfSwitch::value <= + : absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t<(NumCasesOfSwitch::value <= MaxUnrolledVisitCases), VisitIndicesVariadic, VisitIndicesFallback> {}; template struct VisitIndices - : absl::conditional_t<(EndIndex <= MaxUnrolledVisitCases), + : absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t<(EndIndex <= MaxUnrolledVisitCases), VisitIndicesSwitch, VisitIndicesFallback> {}; @@ -577,7 +577,7 @@ struct VariantCoreAccess { template static void Destroy(VariantType& self) { // NOLINT Derived(self).destroy(); - self.index_ = absl::variant_npos; + self.index_ = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_npos; } template @@ -587,7 +587,7 @@ struct VariantCoreAccess { template static void InitFrom(Variant& self, Variant&& other) { // NOLINT - VisitIndices::value>::Run( + VisitIndices::value>::Run( InitFromVisitor{&self, std::forward(other)}, other.index()); @@ -612,7 +612,7 @@ struct VariantCoreAccess { TypedThrowBadVariantAccess>(); } - return Access(absl::forward(self)); + return Access(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(self)); } // The implementation of the move-assignment operation for a variant. @@ -629,7 +629,7 @@ struct VariantCoreAccess { } } - void operator()(SizeT /*new_i*/) const { + void operator()(SizeT /*new_i*/) const { Destroy(*left); } @@ -650,7 +650,7 @@ struct VariantCoreAccess { template void operator()(SizeT /*new_i*/) const { using New = - typename absl::variant_alternative::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative::type; if (left->index_ == NewIndex) { Access(*left) = Access(*right); @@ -662,7 +662,7 @@ struct VariantCoreAccess { } } - void operator()(SizeT /*new_i*/) const { + void operator()(SizeT /*new_i*/) const { Destroy(*left); } @@ -684,24 +684,24 @@ struct VariantCoreAccess { void operator()(SizeT /*old_i*/ ) const { - Access(*left) = absl::forward(other); + Access(*left) = absl::OTABSL_OPTION_NAMESPACE_NAME::forward(other); } template void operator()(SizeT /*old_i*/ ) const { using New = - typename absl::variant_alternative::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative::type; if (std::is_nothrow_constructible::value || !std::is_nothrow_move_constructible::value) { left->template emplace( - absl::forward(other)); + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(other)); } else { // the standard says "equivalent to // operator=(variant(std::forward(t)))", but we use `emplace` here // because the variant's move assignment operator could be deleted. left->template emplace( - New(absl::forward(other))); + New(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(other))); } } @@ -712,18 +712,18 @@ struct VariantCoreAccess { template static ConversionAssignVisitor MakeConversionAssignVisitor(Left* left, QualifiedNew&& qual) { - return {left, absl::forward(qual)}; + return {left, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(qual)}; } // Backend for operations for `emplace()` which destructs `*self` then // construct a new alternative with `Args...`. template - static typename absl::variant_alternative::type& Replace( + static typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative::type& Replace( Self* self, Args&&... args) { Destroy(*self); - using New = typename absl::variant_alternative::type; + using New = typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative::type; New* const result = ::new (static_cast(&self->state_)) - New(absl::forward(args)...); + New(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); self->index_ = NewIndex; return *result; } @@ -738,7 +738,7 @@ struct VariantCoreAccess { Access(std::forward(right))); } - void operator()(SizeT /*new_i*/) const { + void operator()(SizeT /*new_i*/) const { // This space intentionally left blank. } LeftVariant* left; @@ -888,13 +888,13 @@ struct IndexOfConstructedType< template struct ContainsVariantNPos - : absl::negation, - absl::integer_sequence>> {}; + : absl::OTABSL_OPTION_NAMESPACE_NAME::negation, + absl::OTABSL_OPTION_NAMESPACE_NAME::integer_sequence>> {}; template using RawVisitResult = - absl::result_of_t...)>; + absl::OTABSL_OPTION_NAMESPACE_NAME::result_of_t...)>; // NOTE: The spec requires that all return-paths yield the same type and is not // SFINAE-friendly, so we can deduce the return type by examining the first @@ -905,7 +905,7 @@ using RawVisitResult = template struct VisitResultImpl { using type = - absl::result_of_t...)>; + absl::OTABSL_OPTION_NAMESPACE_NAME::result_of_t...)>; }; // Done in two steps intentionally so that we don't cause substitution to fail. @@ -919,7 +919,7 @@ struct PerformVisitation { template constexpr ReturnType operator()(SizeT... indices) const { return Run(typename ContainsVariantNPos::type{}, - absl::index_sequence_for(), indices...); + absl::OTABSL_OPTION_NAMESPACE_NAME::index_sequence_for(), indices...); } template @@ -927,19 +927,19 @@ struct PerformVisitation { index_sequence, SizeT...) const { static_assert( std::is_same...)>>::value, "All visitation overloads must have the same return type."); - return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( - absl::forward(op), + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke( + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(op), VariantCoreAccess::Access( - absl::forward(std::get(variant_tup)))...); + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(std::get(variant_tup)))...); } template [[noreturn]] ReturnType Run(std::true_type /*has_valueless*/, index_sequence, SizeT...) const { - absl::variant_internal::ThrowBadVariantAccess(); + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_internal::ThrowBadVariantAccess(); } // TODO(calabrese) Avoid using a tuple, which causes lots of instantiations @@ -981,11 +981,11 @@ union Union { template explicit constexpr Union(EmplaceTag<0>, P&&... args) - : head(absl::forward

        (args)...) {} + : head(absl::OTABSL_OPTION_NAMESPACE_NAME::forward

        (args)...) {} template explicit constexpr Union(EmplaceTag, P&&... args) - : tail(EmplaceTag{}, absl::forward

        (args)...) {} + : tail(EmplaceTag{}, absl::OTABSL_OPTION_NAMESPACE_NAME::forward

        (args)...) {} Head head; TailUnion tail; @@ -1013,11 +1013,11 @@ union DestructibleUnionImpl { template explicit constexpr DestructibleUnionImpl(EmplaceTag<0>, P&&... args) - : head(absl::forward

        (args)...) {} + : head(absl::OTABSL_OPTION_NAMESPACE_NAME::forward

        (args)...) {} template explicit constexpr DestructibleUnionImpl(EmplaceTag, P&&... args) - : tail(EmplaceTag{}, absl::forward

        (args)...) {} + : tail(EmplaceTag{}, absl::OTABSL_OPTION_NAMESPACE_NAME::forward

        (args)...) {} ~DestructibleUnionImpl() {} @@ -1030,7 +1030,7 @@ union DestructibleUnionImpl { // this resultant type. template using DestructibleUnion = - absl::conditional_t>::value, Union, + absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t>::value, Union, DestructibleUnionImpl>; // Deepest base, containing the actual union and the discriminator @@ -1040,7 +1040,7 @@ class VariantStateBase { using Variant = variant; template ::value, LazyH>> constexpr VariantStateBase() noexcept( std::is_nothrow_default_constructible::value) @@ -1048,7 +1048,7 @@ class VariantStateBase { template explicit constexpr VariantStateBase(EmplaceTag tag, P&&... args) - : state_(tag, absl::forward

        (args)...), index_(I) {} + : state_(tag, absl::OTABSL_OPTION_NAMESPACE_NAME::forward

        (args)...), index_(I) {} explicit constexpr VariantStateBase(NoopConstructorTag) : state_(NoopConstructorTag()), index_(variant_npos) {} @@ -1059,7 +1059,7 @@ class VariantStateBase { std::size_t index_; }; -using absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity; +using absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity; // OverloadSet::Overload() is a unary function which is overloaded to // take any of the element types of the variant, by reference-to-const. @@ -1106,37 +1106,37 @@ using NotEqualResult = decltype(std::declval() != std::declval()); using type_traits_internal::is_detected_convertible; template -using RequireAllHaveEqualT = absl::enable_if_t< - absl::conjunction...>::value, +using RequireAllHaveEqualT = absl::OTABSL_OPTION_NAMESPACE_NAME::enable_if_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction...>::value, bool>; template using RequireAllHaveNotEqualT = - absl::enable_if_t...>::value, bool>; template using RequireAllHaveLessThanT = - absl::enable_if_t...>::value, bool>; template using RequireAllHaveLessThanOrEqualT = - absl::enable_if_t...>::value, bool>; template using RequireAllHaveGreaterThanOrEqualT = - absl::enable_if_t...>::value, bool>; template using RequireAllHaveGreaterThanT = - absl::enable_if_t...>::value, bool>; @@ -1171,7 +1171,7 @@ struct VariantHelper> { template struct CanConvertFrom> - : public absl::conjunction...> {}; + : public absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction...> {}; }; // A type with nontrivial copy ctor and trivial move ctor. @@ -1220,7 +1220,7 @@ class VariantCopyAssignBaseNontrivial; // Base that is dependent on whether or not the destructor can be trivial. template using VariantStateBaseDestructor = - absl::conditional_t>::value, + absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t>::value, VariantStateBase, VariantStateBaseDestructorNontrivial>; @@ -1232,44 +1232,44 @@ using VariantStateBaseDestructor = // So we have to use a different approach (i.e. `HasTrivialMoveConstructor`) to // work around the bug. template -using VariantMoveBase = absl::conditional_t< - absl::disjunction< - absl::negation...>>, - absl::conjunction...>>::value, +using VariantMoveBase = absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::disjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::negation...>>, + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction...>>::value, VariantStateBaseDestructor, VariantMoveBaseNontrivial>; // Base that is dependent on whether or not the copy-constructor can be trivial. template -using VariantCopyBase = absl::conditional_t< - absl::disjunction< - absl::negation...>>, +using VariantCopyBase = absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::disjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::negation...>>, std::is_copy_constructible>>::value, VariantMoveBase, VariantCopyBaseNontrivial>; // Base that is dependent on whether or not the move-assign can be trivial. template -using VariantMoveAssignBase = absl::conditional_t< - absl::disjunction< - absl::conjunction>, +using VariantMoveAssignBase = absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::disjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction>, std::is_move_constructible>, std::is_destructible>>, - absl::negation..., + absl::OTABSL_OPTION_NAMESPACE_NAME::negation..., // Note: We're not qualifying this with - // absl:: because it doesn't compile + // absl::OTABSL_OPTION_NAMESPACE_NAME:: because it doesn't compile // under MSVC. is_move_assignable...>>>::value, VariantCopyBase, VariantMoveAssignBaseNontrivial>; // Base that is dependent on whether or not the copy-assign can be trivial. template -using VariantCopyAssignBase = absl::conditional_t< - absl::disjunction< - absl::conjunction>, +using VariantCopyAssignBase = absl::OTABSL_OPTION_NAMESPACE_NAME::conditional_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::disjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction>, std::is_copy_constructible>, std::is_destructible>>, - absl::negation..., + absl::OTABSL_OPTION_NAMESPACE_NAME::negation..., // Note: We're not qualifying this with - // absl:: because it doesn't compile + // absl::OTABSL_OPTION_NAMESPACE_NAME:: because it doesn't compile // under MSVC. is_copy_assignable...>>>::value, VariantMoveAssignBase, VariantCopyAssignBaseNontrivial>; @@ -1299,11 +1299,11 @@ class VariantStateBaseDestructorNontrivial : protected VariantStateBase { template void operator()(SizeT i) const { using Alternative = - typename absl::variant_alternative>::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type; variant_internal::AccessUnion(self->state_, i).~Alternative(); } - void operator()(SizeT /*i*/) const { + void operator()(SizeT /*i*/) const { // This space intentionally left blank } @@ -1331,12 +1331,12 @@ class VariantMoveBaseNontrivial : protected VariantStateBaseDestructor { template void operator()(SizeT i) const { using Alternative = - typename absl::variant_alternative>::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type; ::new (static_cast(&self->state_)) Alternative( - variant_internal::AccessUnion(absl::move(other->state_), i)); + variant_internal::AccessUnion(absl::OTABSL_OPTION_NAMESPACE_NAME::move(other->state_), i)); } - void operator()(SizeT /*i*/) const {} + void operator()(SizeT /*i*/) const {} VariantMoveBaseNontrivial* self; VariantMoveBaseNontrivial* other; @@ -1344,7 +1344,7 @@ class VariantMoveBaseNontrivial : protected VariantStateBaseDestructor { VariantMoveBaseNontrivial() = default; VariantMoveBaseNontrivial(VariantMoveBaseNontrivial&& other) noexcept( - absl::conjunction...>::value) + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction...>::value) : Base(NoopConstructorTag()) { VisitIndices::Run(Construct{this, &other}, other.index_); index_ = other.index_; @@ -1376,12 +1376,12 @@ class VariantCopyBaseNontrivial : protected VariantMoveBase { template void operator()(SizeT i) const { using Alternative = - typename absl::variant_alternative>::type; + typename absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative>::type; ::new (static_cast(&self->state_)) Alternative(variant_internal::AccessUnion(other->state_, i)); } - void operator()(SizeT /*i*/) const {} + void operator()(SizeT /*i*/) const {} VariantCopyBaseNontrivial* self; const VariantCopyBaseNontrivial* other; @@ -1421,7 +1421,7 @@ class VariantMoveAssignBaseNontrivial : protected VariantCopyBase { VariantMoveAssignBaseNontrivial& operator=(VariantMoveAssignBaseNontrivial&& other) noexcept( - absl::conjunction..., + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction..., std::is_nothrow_move_assignable...>::value) { VisitIndices::Run( VariantCoreAccess::MakeMoveAssignVisitor(this, &other), other.index_); @@ -1471,7 +1471,7 @@ struct EqualsOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return true; } @@ -1486,7 +1486,7 @@ struct NotEqualsOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return false; } @@ -1501,7 +1501,7 @@ struct LessThanOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return false; } @@ -1516,7 +1516,7 @@ struct GreaterThanOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return false; } @@ -1531,7 +1531,7 @@ struct LessThanOrEqualsOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return true; } @@ -1546,7 +1546,7 @@ struct GreaterThanOrEqualsOp { const variant* v; const variant* w; - constexpr bool operator()(SizeT /*v_i*/) const { + constexpr bool operator()(SizeT /*v_i*/) const { return true; } @@ -1584,7 +1584,7 @@ struct Swap { VariantCoreAccess::InitFrom(*v, std::move(tmp)); } - void operator()(SizeT /*w_i*/) const { + void operator()(SizeT /*w_i*/) const { if (!v->valueless_by_exception()) { generic_swap(); } @@ -1618,7 +1618,7 @@ struct VariantHashVisitor { template struct VariantHashBase...>::value>, Ts...> { using argument_type = Variant; diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/variant.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/variant.h index 2649a29ce3c..cbce326c26d 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/variant.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/types/variant.h @@ -16,26 +16,26 @@ // variant.h // ----------------------------------------------------------------------------- // -// This header file defines an `absl::variant` type for holding a type-safe +// This header file defines an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` type for holding a type-safe // value of some prescribed set of types (noted as alternative types), and // associated functions for managing variants. // -// The `absl::variant` type is a form of type-safe union. An `absl::variant` +// The `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` type is a form of type-safe union. An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` // should always hold a value of one of its alternative types (except in the // "valueless by exception state" -- see below). A default-constructed -// `absl::variant` will hold the value of its first alternative type, provided +// `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` will hold the value of its first alternative type, provided // it is default-constructible. // -// In exceptional cases due to error, an `absl::variant` can hold no +// In exceptional cases due to error, an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` can hold no // value (known as a "valueless by exception" state), though this is not the // norm. // -// As with `absl::optional`, an `absl::variant` -- when it holds a value -- +// As with `absl::OTABSL_OPTION_NAMESPACE_NAME::optional`, an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` -- when it holds a value -- // allocates a value of that type directly within the `variant` itself; it // cannot hold a reference, array, or the type `void`; it can, however, hold a // pointer to externally managed memory. // -// `absl::variant` is a C++11 compatible version of the C++17 `std::variant` +// `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` is a C++11 compatible version of the C++17 `std::variant` // abstraction and is designed to be a drop-in replacement for code compliant // with C++17. @@ -82,10 +82,10 @@ namespace absl { OTABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- -// absl::variant +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant // ----------------------------------------------------------------------------- // -// An `absl::variant` type is a form of type-safe union. An `absl::variant` -- +// An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` type is a form of type-safe union. An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` -- // except in exceptional cases -- always holds a value of one of its alternative // types. // @@ -93,29 +93,29 @@ OTABSL_NAMESPACE_BEGIN // // // Construct a variant that holds either an integer or a std::string and // // assign it to a std::string. -// absl::variant v = std::string("abc"); +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant v = std::string("abc"); // // // A default-constructed variant will hold a value-initialized value of // // the first alternative type. -// auto a = absl::variant(); // Holds an int of value '0'. +// auto a = absl::OTABSL_OPTION_NAMESPACE_NAME::variant(); // Holds an int of value '0'. // // // variants are assignable. // // // copy assignment -// auto v1 = absl::variant("abc"); -// auto v2 = absl::variant(10); +// auto v1 = absl::OTABSL_OPTION_NAMESPACE_NAME::variant("abc"); +// auto v2 = absl::OTABSL_OPTION_NAMESPACE_NAME::variant(10); // v2 = v1; // copy assign // // // move assignment -// auto v1 = absl::variant("abc"); -// v1 = absl::variant(10); +// auto v1 = absl::OTABSL_OPTION_NAMESPACE_NAME::variant("abc"); +// v1 = absl::OTABSL_OPTION_NAMESPACE_NAME::variant(10); // // // assignment through type conversion // a = 128; // variant contains int // a = "128"; // variant contains std::string // -// An `absl::variant` holding a value of one of its alternative types `T` holds -// an allocation of `T` directly within the variant itself. An `absl::variant` +// An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` holding a value of one of its alternative types `T` holds +// an allocation of `T` directly within the variant itself. An `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` // is not allowed to allocate additional storage, such as dynamic memory, to // allocate the contained value. The contained value shall be allocated in a // region of the variant storage suitably aligned for all alternative types. @@ -124,8 +124,8 @@ class variant; // swap() // -// Swaps two `absl::variant` values. This function is equivalent to `v.swap(w)` -// where `v` and `w` are `absl::variant` types. +// Swaps two `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` values. This function is equivalent to `v.swap(w)` +// where `v` and `w` are `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` types. // // Note that this function requires all alternative types to be both swappable // and move-constructible, because any two variants may refer to either the same @@ -134,8 +134,8 @@ class variant; // template < typename... Ts, - absl::enable_if_t< - absl::conjunction..., + absl::OTABSL_OPTION_NAMESPACE_NAME::enable_if_t< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction..., type_traits_internal::IsSwappable...>::value, int> = 0> void swap(variant& v, variant& w) noexcept(noexcept(v.swap(w))) { @@ -144,25 +144,25 @@ void swap(variant& v, variant& w) noexcept(noexcept(v.swap(w))) { // variant_size // -// Returns the number of alternative types available for a given `absl::variant` +// Returns the number of alternative types available for a given `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` // type as a compile-time constant expression. As this is a class template, it // is not generally useful for accessing the number of alternative types of -// any given `absl::variant` instance. +// any given `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` instance. // // Example: // -// auto a = absl::variant; +// auto a = absl::OTABSL_OPTION_NAMESPACE_NAME::variant; // constexpr int num_types = -// absl::variant_size>(); +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size>(); // // // You can also use the member constant `value`. // constexpr int num_types = -// absl::variant_size>::value; +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size>::value; // -// // `absl::variant_size` is more valuable for use in generic code: +// // `absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size` is more valuable for use in generic code: // template // constexpr bool IsVariantMultivalue() { -// return absl::variant_size() > 1; +// return absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size() > 1; // } // // Note that the set of cv-qualified specializations of `variant_size` are @@ -189,20 +189,20 @@ struct variant_size : variant_size::type {}; // variant_alternative // -// Returns the alternative type for a given `absl::variant` at the passed +// Returns the alternative type for a given `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` at the passed // index value as a compile-time constant expression. As this is a class // template resulting in a type, it is not useful for access of the run-time -// value of any given `absl::variant` variable. +// value of any given `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` variable. // // Example: // // // The type of the 0th alternative is "int". // using alternative_type_0 -// = absl::variant_alternative<0, absl::variant>::type; +// = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative<0, absl::OTABSL_OPTION_NAMESPACE_NAME::variant>::type; // // static_assert(std::is_same::value, ""); // -// // `absl::variant_alternative` is more valuable for use in generic code: +// // `absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative` is more valuable for use in generic code: // template // constexpr bool IsFirstElementTrivial() { // return std::is_trivial_v::type>; @@ -244,7 +244,7 @@ struct variant_alternative { // Example: // // using alternative_type_0 -// = absl::variant_alternative_t<0, absl::variant>; +// = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t<0, absl::OTABSL_OPTION_NAMESPACE_NAME::variant>; // static_assert(std::is_same::value, ""); template using variant_alternative_t = typename variant_alternative::type; @@ -256,8 +256,8 @@ using variant_alternative_t = typename variant_alternative::type; // // Example: // -// absl::variant foo = 42; -// if (absl::holds_alternative(foo)) { +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant foo = 42; +// if (absl::OTABSL_OPTION_NAMESPACE_NAME::holds_alternative(foo)) { // std::cout << "The variant holds an integer"; // } template @@ -278,22 +278,22 @@ constexpr bool holds_alternative(const variant& v) noexcept { // using a type that is not unique within the variant's set of alternative types // is a compile-time error. If the index of the alternative being specified is // different from the index of the alternative that is currently stored, throws -// `absl::bad_variant_access`. +// `absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access`. // // Example: // -// auto a = absl::variant; +// auto a = absl::OTABSL_OPTION_NAMESPACE_NAME::variant; // // // Get the value by type (if unique). -// int i = absl::get(a); +// int i = absl::OTABSL_OPTION_NAMESPACE_NAME::get(a); // -// auto b = absl::variant; +// auto b = absl::OTABSL_OPTION_NAMESPACE_NAME::variant; // // // Getting the value by a type that is not unique is ill-formed. -// int j = absl::get(b); // Compile Error! +// int j = absl::OTABSL_OPTION_NAMESPACE_NAME::get(b); // Compile Error! // // // Getting value by index not ambiguous and allowed. -// int k = absl::get<1>(b); +// int k = absl::OTABSL_OPTION_NAMESPACE_NAME::get<1>(b); // Overload for getting a variant's lvalue by type. template @@ -303,11 +303,11 @@ constexpr T& get(variant& v) { // NOLINT } // Overload for getting a variant's rvalue by type. -// Note: `absl::move()` is required to allow use of constexpr in C++11. +// Note: `absl::OTABSL_OPTION_NAMESPACE_NAME::move()` is required to allow use of constexpr in C++11. template constexpr T&& get(variant&& v) { return variant_internal::VariantCoreAccess::CheckedAccess< - variant_internal::IndexOf::value>(absl::move(v)); + variant_internal::IndexOf::value>(absl::OTABSL_OPTION_NAMESPACE_NAME::move(v)); } // Overload for getting a variant's const lvalue by type. @@ -318,11 +318,11 @@ constexpr const T& get(const variant& v) { } // Overload for getting a variant's const rvalue by type. -// Note: `absl::move()` is required to allow use of constexpr in C++11. +// Note: `absl::OTABSL_OPTION_NAMESPACE_NAME::move()` is required to allow use of constexpr in C++11. template constexpr const T&& get(const variant&& v) { return variant_internal::VariantCoreAccess::CheckedAccess< - variant_internal::IndexOf::value>(absl::move(v)); + variant_internal::IndexOf::value>(absl::OTABSL_OPTION_NAMESPACE_NAME::move(v)); } // Overload for getting a variant's lvalue by index. @@ -333,11 +333,11 @@ constexpr variant_alternative_t>& get( } // Overload for getting a variant's rvalue by index. -// Note: `absl::move()` is required to allow use of constexpr in C++11. +// Note: `absl::OTABSL_OPTION_NAMESPACE_NAME::move()` is required to allow use of constexpr in C++11. template constexpr variant_alternative_t>&& get( variant&& v) { - return variant_internal::VariantCoreAccess::CheckedAccess(absl::move(v)); + return variant_internal::VariantCoreAccess::CheckedAccess(absl::OTABSL_OPTION_NAMESPACE_NAME::move(v)); } // Overload for getting a variant's const lvalue by index. @@ -348,11 +348,11 @@ constexpr const variant_alternative_t>& get( } // Overload for getting a variant's const rvalue by index. -// Note: `absl::move()` is required to allow use of constexpr in C++11. +// Note: `absl::OTABSL_OPTION_NAMESPACE_NAME::move()` is required to allow use of constexpr in C++11. template constexpr const variant_alternative_t>&& get( const variant&& v) { - return variant_internal::VariantCoreAccess::CheckedAccess(absl::move(v)); + return variant_internal::VariantCoreAccess::CheckedAccess(absl::OTABSL_OPTION_NAMESPACE_NAME::move(v)); } // get_if() @@ -368,7 +368,7 @@ constexpr const variant_alternative_t>&& get( // Overload for getting a pointer to the value stored in the given variant by // index. template -constexpr absl::add_pointer_t>> +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::add_pointer_t>> get_if(variant* v) noexcept { return (v != nullptr && v->index() == I) ? std::addressof( @@ -379,7 +379,7 @@ get_if(variant* v) noexcept { // Overload for getting a pointer to the const value stored in the given // variant by index. template -constexpr absl::add_pointer_t>> +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::add_pointer_t>> get_if(const variant* v) noexcept { return (v != nullptr && v->index() == I) ? std::addressof( @@ -390,21 +390,21 @@ get_if(const variant* v) noexcept { // Overload for getting a pointer to the value stored in the given variant by // type. template -constexpr absl::add_pointer_t get_if(variant* v) noexcept { - return absl::get_if::value>(v); +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::add_pointer_t get_if(variant* v) noexcept { + return absl::OTABSL_OPTION_NAMESPACE_NAME::get_if::value>(v); } // Overload for getting a pointer to the const value stored in the given variant // by type. template -constexpr absl::add_pointer_t get_if( +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::add_pointer_t get_if( const variant* v) noexcept { - return absl::get_if::value>(v); + return absl::OTABSL_OPTION_NAMESPACE_NAME::get_if::value>(v); } // visit() // -// Calls a provided functor on a given set of variants. `absl::visit()` is +// Calls a provided functor on a given set of variants. `absl::OTABSL_OPTION_NAMESPACE_NAME::visit()` is // commonly used to conditionally inspect the state of a given variant (or set // of variants). // @@ -421,19 +421,19 @@ constexpr absl::add_pointer_t get_if( // } // }; // -// // Declare our variant, and call `absl::visit()` on it. +// // Declare our variant, and call `absl::OTABSL_OPTION_NAMESPACE_NAME::visit()` on it. // // Note that `GetVariant()` returns void in either case. -// absl::variant foo = std::string("foo"); +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant foo = std::string("foo"); // GetVariant visitor; -// absl::visit(visitor, foo); // Prints `The variant's value is: foo' +// absl::OTABSL_OPTION_NAMESPACE_NAME::visit(visitor, foo); // Prints `The variant's value is: foo' template variant_internal::VisitResult visit(Visitor&& vis, Variants&&... vars) { return variant_internal:: - VisitIndices >::value...>::Run( + VisitIndices >::value...>::Run( variant_internal::PerformVisitation{ - std::forward_as_tuple(absl::forward(vars)...), - absl::forward(vis)}, + std::forward_as_tuple(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(vars)...), + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(vis)}, vars.index()...); } @@ -443,7 +443,7 @@ variant_internal::VisitResult visit(Visitor&& vis, // which the first variant type is otherwise not default-constructible. struct monostate {}; -// `absl::monostate` Relational Operators +// `absl::OTABSL_OPTION_NAMESPACE_NAME::monostate` Relational Operators constexpr bool operator<(monostate, monostate) noexcept { return false; } constexpr bool operator>(monostate, monostate) noexcept { return false; } @@ -454,20 +454,20 @@ constexpr bool operator!=(monostate, monostate) noexcept { return false; } //------------------------------------------------------------------------------ -// `absl::variant` Template Definition +// `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` Template Definition //------------------------------------------------------------------------------ template class variant : private variant_internal::VariantBase { - static_assert(absl::conjunction, + static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction, std::is_object...>::value, "Attempted to instantiate a variant containing a non-object " "type."); - // Intentionally not qualifying `negation` with `absl::` to work around a bug + // Intentionally not qualifying `negation` with `absl::OTABSL_OPTION_NAMESPACE_NAME::` to work around a bug // in MSVC 2015 with inline namespace and variadic template. - static_assert(absl::conjunction >, + static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction >, negation >...>::value, "Attempted to instantiate a variant containing an array type."); - static_assert(absl::conjunction, + static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction, std::is_nothrow_destructible...>::value, "Attempted to instantiate a variant containing a non-nothrow " "destructible type."); @@ -499,18 +499,18 @@ class variant : private variant_internal::VariantBase { // // NOTE: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0608r1.html // has been voted passed the design phase in the C++ standard meeting in Mar - // 2018. It will be implemented and integrated into `absl::variant`. + // 2018. It will be implemented and integrated into `absl::OTABSL_OPTION_NAMESPACE_NAME::variant`. template < class T, std::size_t I = std::enable_if< variant_internal::IsNeitherSelfNorInPlace>::value, + absl::OTABSL_OPTION_NAMESPACE_NAME::decay_t>::value, variant_internal::IndexOfConstructedType>::type::value, - class Tj = absl::variant_alternative_t, - absl::enable_if_t::value>* = + class Tj = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t, + absl::OTABSL_OPTION_NAMESPACE_NAME::enable_if_t::value>* = nullptr> constexpr variant(T&& t) noexcept(std::is_nothrow_constructible::value) - : Base(variant_internal::EmplaceTag(), absl::forward(t)) {} + : Base(variant_internal::EmplaceTag(), absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t)) {} // Constructs a variant of an alternative type from the arguments through // direct-initialization. @@ -524,7 +524,7 @@ class variant : private variant_internal::VariantBase { constexpr explicit variant(in_place_type_t, Args&&... args) : Base(variant_internal::EmplaceTag< variant_internal::UnambiguousIndexOf::value>(), - absl::forward(args)...) {} + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...) {} // Constructs a variant of an alternative type from an initializer list // and other arguments through direct-initialization. @@ -539,7 +539,7 @@ class variant : private variant_internal::VariantBase { Args&&... args) : Base(variant_internal::EmplaceTag< variant_internal::UnambiguousIndexOf::value>(), - il, absl::forward(args)...) {} + il, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...) {} // Constructs a variant of an alternative type from a provided index, // through value-initialization using the provided forwarded arguments. @@ -548,7 +548,7 @@ class variant : private variant_internal::VariantBase { variant_internal::VariantAlternativeSfinaeT, Args...>::value>::type* = nullptr> constexpr explicit variant(in_place_index_t, Args&&... args) - : Base(variant_internal::EmplaceTag(), absl::forward(args)...) {} + : Base(variant_internal::EmplaceTag(), absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...) {} // Constructs a variant of an alternative type from a provided index, // through value-initialization of an initializer list and the provided @@ -560,12 +560,12 @@ class variant : private variant_internal::VariantBase { constexpr explicit variant(in_place_index_t, std::initializer_list il, Args&&... args) : Base(variant_internal::EmplaceTag(), il, - absl::forward(args)...) {} + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...) {} // Destructors // Destroys the variant's currently contained value, provided that - // `absl::valueless_by_exception()` is false. + // `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false. ~variant() = default; // Assignment Operators @@ -580,13 +580,13 @@ class variant : private variant_internal::VariantBase { // // NOTE: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0608r1.html // has been voted passed the design phase in the C++ standard meeting in Mar - // 2018. It will be implemented and integrated into `absl::variant`. + // 2018. It will be implemented and integrated into `absl::OTABSL_OPTION_NAMESPACE_NAME::variant`. template < class T, std::size_t I = std::enable_if< - !std::is_same, variant>::value, + !std::is_same, variant>::value, variant_internal::IndexOfConstructedType>::type::value, - class Tj = absl::variant_alternative_t, + class Tj = absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t, typename std::enable_if::value && std::is_constructible::value>::type* = nullptr> @@ -595,7 +595,7 @@ class variant : private variant_internal::VariantBase { std::is_nothrow_constructible::value) { variant_internal::VisitIndices::Run( variant_internal::VariantCoreAccess::MakeConversionAssignVisitor( - this, absl::forward(t)), + this, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t)), index()); return *this; @@ -606,89 +606,89 @@ class variant : private variant_internal::VariantBase { // Constructs a value of the given alternative type T within the variant. The // existing value of the variant is destroyed first (provided that - // `absl::valueless_by_exception()` is false). Requires that T is unambiguous + // `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false). Requires that T is unambiguous // in the variant. // // Example: // - // absl::variant, int, std::string> v; + // absl::OTABSL_OPTION_NAMESPACE_NAME::variant, int, std::string> v; // v.emplace(99); // v.emplace("abc"); template < class T, class... Args, typename std::enable_if::value, variant>, Args...>::value>::type* = nullptr> T& emplace(Args&&... args) { return variant_internal::VariantCoreAccess::Replace< variant_internal::UnambiguousIndexOf::value>( - this, absl::forward(args)...); + this, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); } // Constructs a value of the given alternative type T within the variant using // an initializer list. The existing value of the variant is destroyed first - // (provided that `absl::valueless_by_exception()` is false). Requires that T + // (provided that `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false). Requires that T // is unambiguous in the variant. // // Example: // - // absl::variant, int, std::string> v; + // absl::OTABSL_OPTION_NAMESPACE_NAME::variant, int, std::string> v; // v.emplace>({0, 1, 2}); template < class T, class U, class... Args, typename std::enable_if::value, variant>, std::initializer_list&, Args...>::value>::type* = nullptr> T& emplace(std::initializer_list il, Args&&... args) { return variant_internal::VariantCoreAccess::Replace< variant_internal::UnambiguousIndexOf::value>( - this, il, absl::forward(args)...); + this, il, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); } // Destroys the current value of the variant (provided that - // `absl::valueless_by_exception()` is false) and constructs a new value at + // `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false) and constructs a new value at // the given index. // // Example: // - // absl::variant, int, int> v; + // absl::OTABSL_OPTION_NAMESPACE_NAME::variant, int, int> v; // v.emplace<1>(99); // v.emplace<2>(98); // v.emplace(99); // Won't compile. 'int' isn't a unique type. template , + std::is_constructible, Args...>::value>::type* = nullptr> - absl::variant_alternative_t& emplace(Args&&... args) { + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t& emplace(Args&&... args) { return variant_internal::VariantCoreAccess::Replace( - this, absl::forward(args)...); + this, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); } // Destroys the current value of the variant (provided that - // `absl::valueless_by_exception()` is false) and constructs a new value at + // `absl::OTABSL_OPTION_NAMESPACE_NAME::valueless_by_exception()` is false) and constructs a new value at // the given index using an initializer list and the provided arguments. // // Example: // - // absl::variant, int, int> v; + // absl::OTABSL_OPTION_NAMESPACE_NAME::variant, int, int> v; // v.emplace<0>({0, 1, 2}); template , + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t, std::initializer_list&, Args...>::value>::type* = nullptr> - absl::variant_alternative_t& emplace(std::initializer_list il, + absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t& emplace(std::initializer_list il, Args&&... args) { return variant_internal::VariantCoreAccess::Replace( - this, il, absl::forward(args)...); + this, il, absl::OTABSL_OPTION_NAMESPACE_NAME::forward(args)...); } // variant::valueless_by_exception() // // Returns false if and only if the variant currently holds a valid value. constexpr bool valueless_by_exception() const noexcept { - return this->index_ == absl::variant_npos; + return this->index_ == absl::OTABSL_OPTION_NAMESPACE_NAME::variant_npos; } // variant::index() @@ -702,7 +702,7 @@ class variant : private variant_internal::VariantBase { // Swaps the values of two variant objects. // void swap(variant& rhs) noexcept( - absl::conjunction< + absl::OTABSL_OPTION_NAMESPACE_NAME::conjunction< std::is_nothrow_move_constructible, std::is_nothrow_move_constructible..., type_traits_internal::IsNothrowSwappable, @@ -810,14 +810,14 @@ namespace std { // hash() template <> // NOLINT -struct hash { - std::size_t operator()(absl::monostate) const { return 0; } +struct hash { + std::size_t operator()(absl::OTABSL_OPTION_NAMESPACE_NAME::monostate) const { return 0; } }; template // NOLINT -struct hash> - : absl::variant_internal::VariantHashBase, void, - absl::remove_const_t...> {}; +struct hash> + : absl::OTABSL_OPTION_NAMESPACE_NAME::variant_internal::VariantHashBase, void, + absl::OTABSL_OPTION_NAMESPACE_NAME::remove_const_t...> {}; } // namespace std @@ -841,22 +841,22 @@ struct ConversionVisitor { // ConvertVariantTo() // -// Helper functions to convert an `absl::variant` to a variant of another set of +// Helper functions to convert an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` to a variant of another set of // types, provided that the alternative type of the new variant type can be // converted from any type in the source variant. // // Example: // -// absl::variant InternalReq(const Req&); +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant InternalReq(const Req&); // // // name1 and name2 are convertible to name -// absl::variant ExternalReq(const Req& req) { -// return absl::ConvertVariantTo>( +// absl::OTABSL_OPTION_NAMESPACE_NAME::variant ExternalReq(const Req& req) { +// return absl::OTABSL_OPTION_NAMESPACE_NAME::ConvertVariantTo>( // InternalReq(req)); // } template To ConvertVariantTo(Variant&& variant) { - return absl::visit(variant_internal::ConversionVisitor{}, + return absl::OTABSL_OPTION_NAMESPACE_NAME::visit(variant_internal::ConversionVisitor{}, std::forward(variant)); } diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/utility/utility.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/utility/utility.h index 8c15e2b8c10..62580cc5afd 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/utility/utility.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/internal/absl/utility/utility.h @@ -58,7 +58,7 @@ OTABSL_NAMESPACE_BEGIN // Class template representing a compile-time integer sequence. An instantiation // of `integer_sequence` has a sequence of integers encoded in its // type through its template arguments (which is a common need when -// working with C++11 variadic templates). `absl::integer_sequence` is designed +// working with C++11 variadic templates). `absl::OTABSL_OPTION_NAMESPACE_NAME::integer_sequence` is designed // to be a drop-in replacement for C++14's `std::integer_sequence`. // // Example: @@ -81,7 +81,7 @@ struct integer_sequence { // index_sequence // // A helper template for an `integer_sequence` of `size_t`, -// `absl::index_sequence` is designed to be a drop-in replacement for C++14's +// `absl::OTABSL_OPTION_NAMESPACE_NAME::index_sequence` is designed to be a drop-in replacement for C++14's // `std::index_sequence`. template using index_sequence = integer_sequence; @@ -169,7 +169,7 @@ using std::in_place; // in_place_t // // Tag type used to specify in-place construction, such as with -// `absl::optional`, designed to be a drop-in replacement for C++17's +// `absl::OTABSL_OPTION_NAMESPACE_NAME::optional`, designed to be a drop-in replacement for C++17's // `std::in_place_t`. struct in_place_t {}; @@ -185,7 +185,7 @@ using std::in_place_type_t; // in_place_type_t // // Tag type used for in-place construction when the type to construct needs to -// be specified, such as with `absl::any`, designed to be a drop-in replacement +// be specified, such as with `absl::OTABSL_OPTION_NAMESPACE_NAME::any`, designed to be a drop-in replacement // for C++17's `std::in_place_type_t`. template using in_place_type_t = void (*)(utility_internal::InPlaceTypeTag); @@ -202,7 +202,7 @@ using std::in_place_index_t; // in_place_index_t // // Tag type used for in-place construction when the type to construct needs to -// be specified, such as with `absl::any`, designed to be a drop-in replacement +// be specified, such as with `absl::OTABSL_OPTION_NAMESPACE_NAME::any`, designed to be a drop-in replacement // for C++17's `std::in_place_index_t`. template using in_place_index_t = void (*)(utility_internal::InPlaceIndexTag); @@ -218,8 +218,8 @@ void in_place_index(utility_internal::InPlaceIndexTag) {} // A constexpr version of `std::move()`, designed to be a drop-in replacement // for C++14's `std::move()`. template -constexpr absl::remove_reference_t&& move(T&& t) noexcept { - return static_cast&&>(t); +constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::remove_reference_t&& move(T&& t) noexcept { + return static_cast&&>(t); } // forward() @@ -228,7 +228,7 @@ constexpr absl::remove_reference_t&& move(T&& t) noexcept { // for C++14's `std::forward()`. template constexpr T&& forward( - absl::remove_reference_t& t) noexcept { // NOLINT(runtime/references) + absl::OTABSL_OPTION_NAMESPACE_NAME::remove_reference_t& t) noexcept { // NOLINT(runtime/references) return static_cast(t); } @@ -236,12 +236,12 @@ namespace utility_internal { // Helper method for expanding tuple into a called method. template auto apply_helper(Functor&& functor, Tuple&& t, index_sequence) - -> decltype(absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( - absl::forward(functor), - std::get(absl::forward(t))...)) { - return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( - absl::forward(functor), - std::get(absl::forward(t))...); + -> decltype(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke( + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(functor), + std::get(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t))...)) { + return absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke( + absl::OTABSL_OPTION_NAMESPACE_NAME::forward(functor), + std::get(absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t))...); } } // namespace utility_internal @@ -252,7 +252,7 @@ auto apply_helper(Functor&& functor, Tuple&& t, index_sequence) // Each element of the tuple corresponds to an argument of the call (in order). // Both the Callable argument and the tuple argument are perfect-forwarded. // For member-function Callables, the first tuple element acts as the `this` -// pointer. `absl::apply` is designed to be a drop-in replacement for C++17's +// pointer. `absl::OTABSL_OPTION_NAMESPACE_NAME::apply` is designed to be a drop-in replacement for C++17's // `std::apply`. Unlike C++17's `std::apply`, this is not currently `constexpr`. // // Example: @@ -269,57 +269,57 @@ auto apply_helper(Functor&& functor, Tuple&& t, index_sequence) // { // std::tuple tuple1(42, "bar"); // // Invokes the first user function on int, std::string. -// absl::apply(&user_function1, tuple1); +// absl::OTABSL_OPTION_NAMESPACE_NAME::apply(&user_function1, tuple1); // -// std::tuple> tuple2(absl::make_unique()); +// std::tuple> tuple2(absl::OTABSL_OPTION_NAMESPACE_NAME::make_unique()); // // Invokes the user function that takes ownership of the unique // // pointer. -// absl::apply(&user_function2, std::move(tuple2)); +// absl::OTABSL_OPTION_NAMESPACE_NAME::apply(&user_function2, std::move(tuple2)); // -// auto foo = absl::make_unique(); +// auto foo = absl::OTABSL_OPTION_NAMESPACE_NAME::make_unique(); // std::tuple tuple3(foo.get(), 42); // // Invokes the method Bar on foo with one argument, 42. -// absl::apply(&Foo::Bar, tuple3); +// absl::OTABSL_OPTION_NAMESPACE_NAME::apply(&Foo::Bar, tuple3); // // std::tuple tuple4(8, 9); // // Invokes a lambda. -// absl::apply(user_lambda, tuple4); +// absl::OTABSL_OPTION_NAMESPACE_NAME::apply(user_lambda, tuple4); // } template auto apply(Functor&& functor, Tuple&& t) -> decltype(utility_internal::apply_helper( - absl::forward(functor), absl::forward(t), - absl::make_index_sequence(functor), absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t), + absl::OTABSL_OPTION_NAMESPACE_NAME::make_index_sequence::type>::value>{})) { return utility_internal::apply_helper( - absl::forward(functor), absl::forward(t), - absl::make_index_sequence(functor), absl::OTABSL_OPTION_NAMESPACE_NAME::forward(t), + absl::OTABSL_OPTION_NAMESPACE_NAME::make_index_sequence::type>::value>{}); } // exchange // // Replaces the value of `obj` with `new_value` and returns the old value of -// `obj`. `absl::exchange` is designed to be a drop-in replacement for C++14's +// `obj`. `absl::OTABSL_OPTION_NAMESPACE_NAME::exchange` is designed to be a drop-in replacement for C++14's // `std::exchange`. // // Example: // // Foo& operator=(Foo&& other) { -// ptr1_ = absl::exchange(other.ptr1_, nullptr); -// int1_ = absl::exchange(other.int1_, -1); +// ptr1_ = absl::OTABSL_OPTION_NAMESPACE_NAME::exchange(other.ptr1_, nullptr); +// int1_ = absl::OTABSL_OPTION_NAMESPACE_NAME::exchange(other.int1_, -1); // return *this; // } template T exchange(T& obj, U&& new_value) { - T old_value = absl::move(obj); - obj = absl::forward(new_value); + T old_value = absl::OTABSL_OPTION_NAMESPACE_NAME::move(obj); + obj = absl::OTABSL_OPTION_NAMESPACE_NAME::forward(new_value); return old_value; } namespace utility_internal { template -T make_from_tuple_impl(Tuple&& tup, absl::index_sequence) { +T make_from_tuple_impl(Tuple&& tup, absl::OTABSL_OPTION_NAMESPACE_NAME::index_sequence) { return T(std::get(std::forward(tup))...); } } // namespace utility_internal @@ -333,15 +333,15 @@ T make_from_tuple_impl(Tuple&& tup, absl::index_sequence) { // Example: // // std::tuple args("hello world", 5); -// auto s = absl::make_from_tuple(args); +// auto s = absl::OTABSL_OPTION_NAMESPACE_NAME::make_from_tuple(args); // assert(s == "hello"); // template constexpr T make_from_tuple(Tuple&& tup) { return utility_internal::make_from_tuple_impl( std::forward(tup), - absl::make_index_sequence< - std::tuple_size>::value>{}); + absl::OTABSL_OPTION_NAMESPACE_NAME::make_index_sequence< + std::tuple_size>::value>{}); } OTABSL_NAMESPACE_END diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/variant.h b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/variant.h index 6f3837c5883..02df092d0f0 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/variant.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/nostd/variant.h @@ -66,7 +66,6 @@ namespace nostd { # ifdef HAVE_ABSEIL using absl::bad_variant_access; -# endif using absl::get; using absl::get_if; using absl::holds_alternative; @@ -75,6 +74,16 @@ using absl::variant; using absl::variant_alternative_t; using absl::variant_size; using absl::visit; +# else +using absl::OTABSL_OPTION_NAMESPACE_NAME::get; +using absl::OTABSL_OPTION_NAMESPACE_NAME::get_if; +using absl::OTABSL_OPTION_NAMESPACE_NAME::holds_alternative; +using absl::OTABSL_OPTION_NAMESPACE_NAME::monostate; +using absl::OTABSL_OPTION_NAMESPACE_NAME::variant; +using absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t; +using absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size; +using absl::OTABSL_OPTION_NAMESPACE_NAME::visit; +# endif } // namespace nostd OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/client_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/client_attributes.h new file mode 100644 index 00000000000..ec984cc4061 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/client_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace client +{ + +/** + * Client address - domain name if available without reverse DNS lookup; otherwise, IP address or + * Unix domain socket name.

        When observed from the server side, and when communicating through + * an intermediary, @code client.address @endcode SHOULD represent the client address behind any + * intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kClientAddress = "client.address"; + +/** + * Client port number. + *

        + * When observed from the server side, and when communicating through an intermediary, @code + * client.port @endcode SHOULD represent the client port behind any intermediaries, for example + * proxies, if it's available. + */ +static constexpr const char *kClientPort = "client.port"; + +} // namespace client +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/error_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/error_attributes.h new file mode 100644 index 00000000000..1b711ff112d --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/error_attributes.h @@ -0,0 +1,57 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace error +{ + +/** + * Describes a class of error the operation ended with. + *

        + * The @code error.type @endcode SHOULD be predictable, and SHOULD have low cardinality. + *

        + * When @code error.type @endcode is set to a type (e.g., an exception type), its + * canonical class name identifying the type within the artifact SHOULD be used. + *

        + * Instrumentations SHOULD document the list of errors they report. + *

        + * The cardinality of @code error.type @endcode within one instrumentation library SHOULD be low. + * Telemetry consumers that aggregate data from multiple instrumentation libraries and applications + * should be prepared for @code error.type @endcode 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 + * @endcode.

        If a specific domain defines its own set of error identifiers (such as HTTP or gRPC + * status codes), it's RECOMMENDED to:

        • Use a domain-specific attribute
        • Set + * @code error.type @endcode to capture all errors, regardless of whether they are defined within + * the domain-specific set or not.
        • + *
        + */ +static constexpr const char *kErrorType = "error.type"; + +namespace ErrorTypeValues +{ +/** + * A fallback error value to be used when the instrumentation doesn't define a custom value. + */ +static constexpr const char *kOther = "_OTHER"; + +} // namespace ErrorTypeValues + +} // namespace error +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/exception_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/exception_attributes.h new file mode 100644 index 00000000000..fdc19ac6d0e --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/exception_attributes.h @@ -0,0 +1,59 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace exception +{ + +/** + * SHOULD be set to true if the exception event is recorded at a point where it is known that the + * exception is escaping the scope of the span.

        An exception is considered to have escaped (or + * left) the scope of a span, if that span is ended while the exception is still logically "in + * flight". This may be actually "in flight" in some languages (e.g. if the exception is passed to a + * Context manager's @code __exit__ @endcode method in Python) but will usually be caught at the + * point of recording the exception in most languages.

        It is usually not possible to determine + * at the point where an exception is thrown whether it will escape the scope of a span. However, it + * is trivial to know that an exception will escape, if one checks for an active exception just + * before ending the span, as done in the example + * for recording span exceptions.

        It follows that an exception may still escape the scope of + * the span even if the @code exception.escaped @endcode attribute was not set or set to false, + * since the event might have been recorded at a time where it was not + * clear whether the exception will escape. + */ +static constexpr const char *kExceptionEscaped = "exception.escaped"; + +/** + * The exception message. + */ +static constexpr const char *kExceptionMessage = "exception.message"; + +/** + * A stacktrace as a string in the natural representation for the language runtime. The + * representation is to be determined and documented by each language SIG. + */ +static constexpr const char *kExceptionStacktrace = "exception.stacktrace"; + +/** + * 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. + */ +static constexpr const char *kExceptionType = "exception.type"; + +} // namespace exception +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/http_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/http_attributes.h new file mode 100644 index 00000000000..6011674e842 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/http_attributes.h @@ -0,0 +1,153 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace http +{ + +/** + * HTTP request headers, @code @endcode being the normalized HTTP Header name (lowercase), the + * value being the header values.

        Instrumentations SHOULD require an explicit configuration of + * which headers are to be captured. Including all request headers can be a security risk - explicit + * configuration helps avoid leaking sensitive information. The @code User-Agent @endcode header is + * already captured in the @code user_agent.original @endcode attribute. Users MAY explicitly + * configure instrumentations to capture them even though it is not recommended. The attribute value + * MUST consist of either multiple header values as an array of strings or a single-item array + * containing a possibly comma-concatenated string, depending on the way the HTTP library provides + * access to headers. + */ +static constexpr const char *kHttpRequestHeader = "http.request.header"; + +/** + * HTTP request method. + *

        + * 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 + * @endcode attribute to @code _OTHER @endcode.

        If the HTTP instrumentation could end up + * converting valid HTTP request methods to @code _OTHER @endcode, 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 @endcode 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 @endcode to the + * original value. + */ +static constexpr const char *kHttpRequestMethod = "http.request.method"; + +/** + * Original HTTP method sent by the client in the request line. + */ +static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original"; + +/** + * The ordinal number of request resending attempt (for any reason, including redirects). + *

        + * 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 *kHttpRequestResendCount = "http.request.resend_count"; + +/** + * HTTP response headers, @code @endcode being the normalized HTTP Header name (lowercase), + * the value being the header values.

        Instrumentations SHOULD require an explicit configuration + * of which headers are to be captured. Including all response headers can be a security risk - + * explicit configuration helps avoid leaking sensitive information. Users MAY explicitly configure + * instrumentations to capture them even though it is not recommended. The attribute value MUST + * consist of either multiple header values as an array of strings or a single-item array containing + * a possibly comma-concatenated string, depending on the way the HTTP library provides access to + * headers. + */ +static constexpr const char *kHttpResponseHeader = "http.response.header"; + +/** + * HTTP response status code. + */ +static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; + +/** + * The matched route, that is, the path template in the format used by the respective server + * framework.

        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 *kHttpRoute = "http.route"; + +namespace HttpRequestMethodValues +{ +/** + * CONNECT method. + */ +static constexpr const char *kConnect = "CONNECT"; + +/** + * DELETE method. + */ +static constexpr const char *kDelete = "DELETE"; + +/** + * GET method. + */ +static constexpr const char *kGet = "GET"; + +/** + * HEAD method. + */ +static constexpr const char *kHead = "HEAD"; + +/** + * OPTIONS method. + */ +static constexpr const char *kOptions = "OPTIONS"; + +/** + * PATCH method. + */ +static constexpr const char *kPatch = "PATCH"; + +/** + * POST method. + */ +static constexpr const char *kPost = "POST"; + +/** + * PUT method. + */ +static constexpr const char *kPut = "PUT"; + +/** + * TRACE method. + */ +static constexpr const char *kTrace = "TRACE"; + +/** + * Any HTTP method that the instrumentation has no prior knowledge of. + */ +static constexpr const char *kOther = "_OTHER"; + +} // namespace HttpRequestMethodValues + +} // namespace http +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/http_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/http_metrics.h new file mode 100644 index 00000000000..f83172e80ec --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/http_metrics.h @@ -0,0 +1,79 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace http +{ + +/** + * Duration of HTTP client requests. + *

        + * histogram + */ +static constexpr const char *kMetricHttpClientRequestDuration = + "metric.http.client.request.duration"; +static constexpr const char *descrMetricHttpClientRequestDuration = + "Duration of HTTP client requests."; +static constexpr const char *unitMetricHttpClientRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientRequestDuration, + descrMetricHttpClientRequestDuration, + unitMetricHttpClientRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientRequestDuration, + descrMetricHttpClientRequestDuration, + unitMetricHttpClientRequestDuration); +} + +/** + * Duration of HTTP server requests. + *

        + * histogram + */ +static constexpr const char *kMetricHttpServerRequestDuration = + "metric.http.server.request.duration"; +static constexpr const char *descrMetricHttpServerRequestDuration = + "Duration of HTTP server requests."; +static constexpr const char *unitMetricHttpServerRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpServerRequestDuration, + descrMetricHttpServerRequestDuration, + unitMetricHttpServerRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpServerRequestDuration, + descrMetricHttpServerRequestDuration, + unitMetricHttpServerRequestDuration); +} + +} // namespace http +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/artifact_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/artifact_attributes.h new file mode 100644 index 00000000000..d3bb99f6e5b --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/artifact_attributes.h @@ -0,0 +1,81 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace artifact +{ + +/** + * The provenance filename of the built attestation which directly relates to the build artifact + * filename. This filename SHOULD accompany the artifact at publish time. See the SLSA + * Relationship specification for more information. + */ +static constexpr const char *kArtifactAttestationFilename = "artifact.attestation.filename"; + +/** + * The full hash value (see + * glossary), of the built attestation. Some envelopes in the software attestation space also + * refer to this as the digest. + */ +static constexpr const char *kArtifactAttestationHash = "artifact.attestation.hash"; + +/** + * The id of the build software attestation. + */ +static constexpr const char *kArtifactAttestationId = "artifact.attestation.id"; + +/** + * The human readable file name of the artifact, typically generated during build and release + * processes. Often includes the package name and version in the file name.

        This file name can + * also act as the Package Name + * in cases where the package ecosystem maps accordingly. + * Additionally, the artifact can be published for + * others, but that is not a guarantee. + */ +static constexpr const char *kArtifactFilename = "artifact.filename"; + +/** + * The full hash value (see + * glossary), often found in checksum.txt on a release of the artifact and used to verify + * package integrity.

        The specific algorithm used to create the cryptographic hash value is not + * defined. In situations where an artifact has multiple cryptographic hashes, it is up to the + * implementer to choose which hash value to set here; this should be the most secure hash algorithm + * that is suitable for the situation and consistent with the + * corresponding attestation. The implementer can then provide the other + * hash values through an additional set of attribute extensions as they + * deem necessary. + */ +static constexpr const char *kArtifactHash = "artifact.hash"; + +/** + * The Package URL of the package artifact provides a + * standard way to identify and locate the packaged artifact. + */ +static constexpr const char *kArtifactPurl = "artifact.purl"; + +/** + * The version of the artifact. + */ +static constexpr const char *kArtifactVersion = "artifact.version"; + +} // namespace artifact +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/aws_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/aws_attributes.h new file mode 100644 index 00000000000..d0eaa6d08a0 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/aws_attributes.h @@ -0,0 +1,356 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace aws +{ + +/** + * The JSON-serialized value of each item in the @code AttributeDefinitions @endcode request field. + */ +static constexpr const char *kAwsDynamodbAttributeDefinitions = + "aws.dynamodb.attribute_definitions"; + +/** + * The value of the @code AttributesToGet @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbAttributesToGet = "aws.dynamodb.attributes_to_get"; + +/** + * The value of the @code ConsistentRead @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consistent_read"; + +/** + * The JSON-serialized value of each item in the @code ConsumedCapacity @endcode response field. + */ +static constexpr const char *kAwsDynamodbConsumedCapacity = "aws.dynamodb.consumed_capacity"; + +/** + * The value of the @code Count @endcode response parameter. + */ +static constexpr const char *kAwsDynamodbCount = "aws.dynamodb.count"; + +/** + * The value of the @code ExclusiveStartTableName @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbExclusiveStartTable = "aws.dynamodb.exclusive_start_table"; + +/** + * The JSON-serialized value of each item in the @code GlobalSecondaryIndexUpdates @endcode request + * field. + */ +static constexpr const char *kAwsDynamodbGlobalSecondaryIndexUpdates = + "aws.dynamodb.global_secondary_index_updates"; + +/** + * The JSON-serialized value of each item of the @code GlobalSecondaryIndexes @endcode request field + */ +static constexpr const char *kAwsDynamodbGlobalSecondaryIndexes = + "aws.dynamodb.global_secondary_indexes"; + +/** + * The value of the @code IndexName @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbIndexName = "aws.dynamodb.index_name"; + +/** + * The JSON-serialized value of the @code ItemCollectionMetrics @endcode response field. + */ +static constexpr const char *kAwsDynamodbItemCollectionMetrics = + "aws.dynamodb.item_collection_metrics"; + +/** + * The value of the @code Limit @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbLimit = "aws.dynamodb.limit"; + +/** + * The JSON-serialized value of each item of the @code LocalSecondaryIndexes @endcode request field. + */ +static constexpr const char *kAwsDynamodbLocalSecondaryIndexes = + "aws.dynamodb.local_secondary_indexes"; + +/** + * The value of the @code ProjectionExpression @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbProjection = "aws.dynamodb.projection"; + +/** + * The value of the @code ProvisionedThroughput.ReadCapacityUnits @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbProvisionedReadCapacity = + "aws.dynamodb.provisioned_read_capacity"; + +/** + * The value of the @code ProvisionedThroughput.WriteCapacityUnits @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbProvisionedWriteCapacity = + "aws.dynamodb.provisioned_write_capacity"; + +/** + * The value of the @code ScanIndexForward @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbScanForward = "aws.dynamodb.scan_forward"; + +/** + * The value of the @code ScannedCount @endcode response parameter. + */ +static constexpr const char *kAwsDynamodbScannedCount = "aws.dynamodb.scanned_count"; + +/** + * The value of the @code Segment @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbSegment = "aws.dynamodb.segment"; + +/** + * The value of the @code Select @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbSelect = "aws.dynamodb.select"; + +/** + * The number of items in the @code TableNames @endcode response parameter. + */ +static constexpr const char *kAwsDynamodbTableCount = "aws.dynamodb.table_count"; + +/** + * The keys in the @code RequestItems @endcode object field. + */ +static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names"; + +/** + * The value of the @code TotalSegments @endcode request parameter. + */ +static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; + +/** + * The ARN of an ECS cluster. + */ +static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; + +/** + * The Amazon Resource Name (ARN) of an ECS + * container instance. + */ +static constexpr const char *kAwsEcsContainerArn = "aws.ecs.container.arn"; + +/** + * The launch + * type for an ECS task. + */ +static constexpr const char *kAwsEcsLaunchtype = "aws.ecs.launchtype"; + +/** + * The ARN of a running ECS + * task. + */ +static constexpr const char *kAwsEcsTaskArn = "aws.ecs.task.arn"; + +/** + * The family name of the ECS task + * definition used to create the ECS task. + */ +static constexpr const char *kAwsEcsTaskFamily = "aws.ecs.task.family"; + +/** + * The ID of a running ECS task. The ID MUST be extracted from @code task.arn @endcode. + */ +static constexpr const char *kAwsEcsTaskId = "aws.ecs.task.id"; + +/** + * The revision for the task definition used to create the ECS task. + */ +static constexpr const char *kAwsEcsTaskRevision = "aws.ecs.task.revision"; + +/** + * The ARN of an EKS cluster. + */ +static constexpr const char *kAwsEksClusterArn = "aws.eks.cluster.arn"; + +/** + * The full invoked ARN as provided on the @code Context @endcode passed to the function (@code + * Lambda-Runtime-Invoked-Function-Arn @endcode header on the @code /runtime/invocation/next + * @endcode applicable).

        This may be different from @code cloud.resource_id @endcode if an alias + * is involved. + */ +static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; + +/** + * The Amazon Resource Name(s) (ARN) of the AWS log group(s). + *

        + * See the log + * group ARN format documentation. + */ +static constexpr const char *kAwsLogGroupArns = "aws.log.group.arns"; + +/** + * The name(s) of the AWS log group(s) an application is writing to. + *

        + * 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 ARN(s) of the AWS log stream(s). + *

        + * See the log + * stream ARN format documentation. One log group can contain several log streams, so these ARNs + * necessarily identify both a log group and a log stream. + */ +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 AWS request ID as returned in the response headers @code x-amz-request-id @endcode or @code + * x-amz-requestid @endcode. + */ +static constexpr const char *kAwsRequestId = "aws.request_id"; + +/** + * The S3 bucket name the request refers to. Corresponds to the @code --bucket @endcode parameter of + * the S3 API + * operations.

        The @code bucket @endcode attribute is applicable to all S3 operations that + * reference a bucket, i.e. that require the bucket name as a mandatory parameter. This applies to + * almost all S3 operations except @code list-buckets @endcode. + */ +static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; + +/** + * The source object (in the form @code bucket @endcode/@code key @endcode) for the copy operation. + *

        + * The @code copy_source @endcode attribute applies to S3 copy operations and corresponds to the + * @code --copy-source @endcode parameter of the copy-object + * operation within the S3 API. This applies in particular to the following operations:

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

        + * The @code delete @endcode attribute is only applicable to the delete-object + * operation. The @code delete @endcode attribute corresponds to the @code --delete @endcode + * parameter of the delete-objects + * operation within the S3 API. + */ +static constexpr const char *kAwsS3Delete = "aws.s3.delete"; + +/** + * The S3 object key the request refers to. Corresponds to the @code --key @endcode parameter of the + * S3 API + * operations.

        The @code key @endcode attribute is applicable to all object-related S3 + * operations, i.e. that require the object key as a mandatory parameter. This applies in particular + * to the following operations:

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

        The @code part_number @endcode attribute is only applicable to + * the upload-part + * and upload-part-copy + * operations. The @code part_number @endcode attribute corresponds to the @code --part-number + * @endcode parameter of the upload-part + * operation within the S3 API. + */ +static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; + +/** + * Upload ID that identifies the multipart upload. + *

        + * The @code upload_id @endcode attribute applies to S3 multipart-upload operations and corresponds + * to the @code --upload-id @endcode parameter of the S3 API multipart + * operations. This applies in particular to the following operations:

        + */ +static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; + +namespace AwsEcsLaunchtypeValues +{ +/** + * none + */ +static constexpr const char *kEc2 = "ec2"; + +/** + * none + */ +static constexpr const char *kFargate = "fargate"; + +} // namespace AwsEcsLaunchtypeValues + +} // namespace aws +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/az_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/az_attributes.h new file mode 100644 index 00000000000..2ce360d870c --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/az_attributes.h @@ -0,0 +1,37 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace az +{ + +/** + * Azure + * Resource Provider Namespace as recognized by the client. + */ +static constexpr const char *kAzNamespace = "az.namespace"; + +/** + * The unique identifier of the service request. It's generated by the Azure service and returned + * with the response. + */ +static constexpr const char *kAzServiceRequestId = "az.service_request_id"; + +} // namespace az +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/browser_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/browser_attributes.h new file mode 100644 index 00000000000..5ddb61eae54 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/browser_attributes.h @@ -0,0 +1,65 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace browser +{ + +/** + * Array of brand name and version separated by a space + *

        + * This value is intended to be taken from the UA client hints API (@code + * navigator.userAgentData.brands @endcode). + */ +static constexpr const char *kBrowserBrands = "browser.brands"; + +/** + * Preferred language of the user using the browser + *

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

        + * This value is intended to be taken from the UA client hints API (@code + * navigator.userAgentData.mobile @endcode). If unavailable, this attribute SHOULD be left unset. + */ +static constexpr const char *kBrowserMobile = "browser.mobile"; + +/** + * The platform on which the browser is running + *

        + * This value is intended to be taken from the UA client hints API (@code + * navigator.userAgentData.platform @endcode). If unavailable, the legacy @code navigator.platform + * @endcode API SHOULD NOT be used instead and this attribute SHOULD be left unset in order for the + * values to be consistent. The list of possible values is defined in the W3C User-Agent Client Hints + * specification. Note that some (but not all) of these values can overlap with values in the @code os.type @endcode and @code os.name @endcode attributes. However, for + * consistency, the values in the @code browser.platform @endcode attribute should capture the exact + * value that the user agent provides. + */ +static constexpr const char *kBrowserPlatform = "browser.platform"; + +} // namespace browser +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cicd_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cicd_attributes.h new file mode 100644 index 00000000000..246563a8e8d --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cicd_attributes.h @@ -0,0 +1,76 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cicd +{ + +/** + * The human readable name of the pipeline within a CI/CD system. + */ +static constexpr const char *kCicdPipelineName = "cicd.pipeline.name"; + +/** + * The unique identifier of a pipeline run within a CI/CD system. + */ +static constexpr const char *kCicdPipelineRunId = "cicd.pipeline.run.id"; + +/** + * The human readable name of a task within a pipeline. Task here most closely aligns with a computing process in a pipeline. + * Other terms for tasks include commands, steps, and procedures. + */ +static constexpr const char *kCicdPipelineTaskName = "cicd.pipeline.task.name"; + +/** + * The unique identifier of a task run within a pipeline. + */ +static constexpr const char *kCicdPipelineTaskRunId = "cicd.pipeline.task.run.id"; + +/** + * The URL of the pipeline run providing the + * complete address in order to locate and identify the pipeline run. + */ +static constexpr const char *kCicdPipelineTaskRunUrlFull = "cicd.pipeline.task.run.url.full"; + +/** + * The type of the task within a pipeline. + */ +static constexpr const char *kCicdPipelineTaskType = "cicd.pipeline.task.type"; + +namespace CicdPipelineTaskTypeValues +{ +/** + * build + */ +static constexpr const char *kBuild = "build"; + +/** + * test + */ +static constexpr const char *kTest = "test"; + +/** + * deploy + */ +static constexpr const char *kDeploy = "deploy"; + +} // namespace CicdPipelineTaskTypeValues + +} // namespace cicd +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/client_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/client_attributes.h new file mode 100644 index 00000000000..ec984cc4061 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/client_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace client +{ + +/** + * Client address - domain name if available without reverse DNS lookup; otherwise, IP address or + * Unix domain socket name.

        When observed from the server side, and when communicating through + * an intermediary, @code client.address @endcode SHOULD represent the client address behind any + * intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kClientAddress = "client.address"; + +/** + * Client port number. + *

        + * When observed from the server side, and when communicating through an intermediary, @code + * client.port @endcode SHOULD represent the client port behind any intermediaries, for example + * proxies, if it's available. + */ +static constexpr const char *kClientPort = "client.port"; + +} // namespace client +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloud_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloud_attributes.h new file mode 100644 index 00000000000..6720eb3edf8 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloud_attributes.h @@ -0,0 +1,272 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cloud +{ + +/** + * 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.

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

        + * The prefix of the service SHOULD match the one specified in @code cloud.provider @endcode. + */ +static constexpr const char *kCloudPlatform = "cloud.platform"; + +/** + * Name of the cloud provider. + */ +static constexpr const char *kCloudProvider = "cloud.provider"; + +/** + * The geographical region the resource is running. + *

        + * Refer to your provider's docs to see the available regions, for example Alibaba Cloud regions, AWS regions, Azure regions, Google Cloud regions, or Tencent Cloud regions. + */ +static constexpr const char *kCloudRegion = "cloud.region"; + +/** + * Cloud provider-specific native identifier of the monitored cloud resource (e.g. an ARN on AWS, + * a fully qualified + * resource ID on Azure, a full resource + * name on GCP)

        On some cloud providers, it may not be possible to determine the full ID at + * startup, so it may be necessary to set @code cloud.resource_id @endcode as a span attribute + * instead.

        The exact value to use for @code cloud.resource_id @endcode depends on the cloud + * provider. The following well-known definitions MUST be used if you set this attribute and they + * apply:

        • AWS Lambda: The function ARN. Take + * care not to use the "invoked ARN" directly but replace any alias suffix + * with the resolved function version, as the same runtime instance may be invocable with + * multiple different aliases.
        • + *
        • GCP: The URI of the resource
        • + *
        • Azure: The Fully Qualified Resource + * ID of the invoked function, not the function app, having the form + * @code + * /subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/ + * @endcode. This means that a span attribute MUST be used, as an Azure function app can host + * multiple functions that would usually share a TracerProvider.
        • + *
        + */ +static constexpr const char *kCloudResourceId = "cloud.resource_id"; + +namespace CloudPlatformValues +{ +/** + * Alibaba Cloud Elastic Compute Service + */ +static constexpr const char *kAlibabaCloudEcs = "alibaba_cloud_ecs"; + +/** + * Alibaba Cloud Function Compute + */ +static constexpr const char *kAlibabaCloudFc = "alibaba_cloud_fc"; + +/** + * Red Hat OpenShift on Alibaba Cloud + */ +static constexpr const char *kAlibabaCloudOpenshift = "alibaba_cloud_openshift"; + +/** + * AWS Elastic Compute Cloud + */ +static constexpr const char *kAwsEc2 = "aws_ec2"; + +/** + * AWS Elastic Container Service + */ +static constexpr const char *kAwsEcs = "aws_ecs"; + +/** + * AWS Elastic Kubernetes Service + */ +static constexpr const char *kAwsEks = "aws_eks"; + +/** + * AWS Lambda + */ +static constexpr const char *kAwsLambda = "aws_lambda"; + +/** + * AWS Elastic Beanstalk + */ +static constexpr const char *kAwsElasticBeanstalk = "aws_elastic_beanstalk"; + +/** + * AWS App Runner + */ +static constexpr const char *kAwsAppRunner = "aws_app_runner"; + +/** + * Red Hat OpenShift on AWS (ROSA) + */ +static constexpr const char *kAwsOpenshift = "aws_openshift"; + +/** + * Azure Virtual Machines + */ +static constexpr const char *kAzureVm = "azure_vm"; + +/** + * Azure Container Apps + */ +static constexpr const char *kAzureContainerApps = "azure_container_apps"; + +/** + * Azure Container Instances + */ +static constexpr const char *kAzureContainerInstances = "azure_container_instances"; + +/** + * Azure Kubernetes Service + */ +static constexpr const char *kAzureAks = "azure_aks"; + +/** + * Azure Functions + */ +static constexpr const char *kAzureFunctions = "azure_functions"; + +/** + * Azure App Service + */ +static constexpr const char *kAzureAppService = "azure_app_service"; + +/** + * Azure Red Hat OpenShift + */ +static constexpr const char *kAzureOpenshift = "azure_openshift"; + +/** + * Google Bare Metal Solution (BMS) + */ +static constexpr const char *kGcpBareMetalSolution = "gcp_bare_metal_solution"; + +/** + * Google Cloud Compute Engine (GCE) + */ +static constexpr const char *kGcpComputeEngine = "gcp_compute_engine"; + +/** + * Google Cloud Run + */ +static constexpr const char *kGcpCloudRun = "gcp_cloud_run"; + +/** + * Google Cloud Kubernetes Engine (GKE) + */ +static constexpr const char *kGcpKubernetesEngine = "gcp_kubernetes_engine"; + +/** + * Google Cloud Functions (GCF) + */ +static constexpr const char *kGcpCloudFunctions = "gcp_cloud_functions"; + +/** + * Google Cloud App Engine (GAE) + */ +static constexpr const char *kGcpAppEngine = "gcp_app_engine"; + +/** + * Red Hat OpenShift on Google Cloud + */ +static constexpr const char *kGcpOpenshift = "gcp_openshift"; + +/** + * Red Hat OpenShift on IBM Cloud + */ +static constexpr const char *kIbmCloudOpenshift = "ibm_cloud_openshift"; + +/** + * Tencent Cloud Cloud Virtual Machine (CVM) + */ +static constexpr const char *kTencentCloudCvm = "tencent_cloud_cvm"; + +/** + * Tencent Cloud Elastic Kubernetes Service (EKS) + */ +static constexpr const char *kTencentCloudEks = "tencent_cloud_eks"; + +/** + * Tencent Cloud Serverless Cloud Function (SCF) + */ +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 cloud +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h new file mode 100644 index 00000000000..363feed1570 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h @@ -0,0 +1,58 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cloudevents +{ + +/** + * The event_id + * uniquely identifies the event. + */ +static constexpr const char *kCloudeventsEventId = "cloudevents.event_id"; + +/** + * The source + * identifies the context in which an event happened. + */ +static constexpr const char *kCloudeventsEventSource = "cloudevents.event_source"; + +/** + * The version of + * the CloudEvents specification which the event uses. + */ +static constexpr const char *kCloudeventsEventSpecVersion = "cloudevents.event_spec_version"; + +/** + * The subject of + * the event in the context of the event producer (identified by source). + */ +static constexpr const char *kCloudeventsEventSubject = "cloudevents.event_subject"; + +/** + * The event_type + * contains a value describing the type of event related to the originating occurrence. + */ +static constexpr const char *kCloudeventsEventType = "cloudevents.event_type"; + +} // namespace cloudevents +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h new file mode 100644 index 00000000000..0eda006baa6 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h @@ -0,0 +1,138 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cloudfoundry +{ + +/** + * The guid of the application. + *

        + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.application_id @endcode. This is the same value as + * reported by @code cf app --guid @endcode. + */ +static constexpr const char *kCloudfoundryAppId = "cloudfoundry.app.id"; + +/** + * The index of the application instance. 0 when just one instance is active. + *

        + * CloudFoundry defines the @code instance_id @endcode in the Loggegator v2 envelope. It + * is used for logs and metrics emitted by CloudFoundry. It is supposed to contain the application + * instance index for applications deployed on the runtime.

        Application instrumentation should + * use the value from environment variable @code CF_INSTANCE_INDEX @endcode. + */ +static constexpr const char *kCloudfoundryAppInstanceId = "cloudfoundry.app.instance.id"; + +/** + * The name of the application. + *

        + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.application_name @endcode. This is the same value + * as reported by @code cf apps @endcode. + */ +static constexpr const char *kCloudfoundryAppName = "cloudfoundry.app.name"; + +/** + * The guid of the CloudFoundry org the application is running in. + *

        + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.org_id @endcode. This is the same value as + * reported by @code cf org --guid @endcode. + */ +static constexpr const char *kCloudfoundryOrgId = "cloudfoundry.org.id"; + +/** + * The name of the CloudFoundry organization the app is running in. + *

        + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.org_name @endcode. This is the same value as + * reported by @code cf orgs @endcode. + */ +static constexpr const char *kCloudfoundryOrgName = "cloudfoundry.org.name"; + +/** + * The UID identifying the process. + *

        + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.process_id @endcode. It is supposed to be equal to + * @code VCAP_APPLICATION.app_id @endcode for applications deployed to the runtime. + * For system components, this could be the actual PID. + */ +static constexpr const char *kCloudfoundryProcessId = "cloudfoundry.process.id"; + +/** + * The type of process. + *

        + * CloudFoundry applications can consist of multiple jobs. Usually the + * main process will be of type @code web @endcode. There can be additional background + * tasks or side-cars with different process types. + */ +static constexpr const char *kCloudfoundryProcessType = "cloudfoundry.process.type"; + +/** + * The guid of the CloudFoundry space the application is running in. + *

        + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.space_id @endcode. This is the same value as + * reported by @code cf space --guid @endcode. + */ +static constexpr const char *kCloudfoundrySpaceId = "cloudfoundry.space.id"; + +/** + * The name of the CloudFoundry space the application is running in. + *

        + * Application instrumentation should use the value from environment + * variable @code VCAP_APPLICATION.space_name @endcode. This is the same value as + * reported by @code cf spaces @endcode. + */ +static constexpr const char *kCloudfoundrySpaceName = "cloudfoundry.space.name"; + +/** + * A guid or another name describing the event source. + *

        + * CloudFoundry defines the @code source_id @endcode in the Loggregator v2 envelope. + * It is used for logs and metrics emitted by CloudFoundry. It is + * supposed to contain the component name, e.g. "gorouter", for + * CloudFoundry components. + *

        + * When system components are instrumented, values from the + * Bosh spec + * should be used. The @code system.id @endcode should be set to + * @code spec.deployment/spec.name @endcode. + */ +static constexpr const char *kCloudfoundrySystemId = "cloudfoundry.system.id"; + +/** + * A guid describing the concrete instance of the event source. + *

        + * CloudFoundry defines the @code instance_id @endcode in the Loggregator v2 envelope. + * It is used for logs and metrics emitted by CloudFoundry. It is + * supposed to contain the vm id for CloudFoundry components. + *

        + * When system components are instrumented, values from the + * Bosh spec + * should be used. The @code system.instance.id @endcode should be set to @code spec.id @endcode. + */ +static constexpr const char *kCloudfoundrySystemInstanceId = "cloudfoundry.system.instance.id"; + +} // namespace cloudfoundry +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/code_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/code_attributes.h new file mode 100644 index 00000000000..f2715e87b66 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/code_attributes.h @@ -0,0 +1,60 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace code +{ + +/** + * The column number in @code code.filepath @endcode best representing the operation. It SHOULD + * point within the code unit named in @code code.function @endcode. + */ +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 @endcode best representing the operation. It SHOULD point + * within the code unit named in @code code.function @endcode. + */ +static constexpr const char *kCodeLineno = "code.lineno"; + +/** + * The "namespace" within which @code code.function @endcode is defined. Usually the qualified class + * or module name, such that @code code.namespace @endcode + some separator + @code code.function + * @endcode form a unique identifier for the code unit. + */ +static constexpr const char *kCodeNamespace = "code.namespace"; + +/** + * 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. + */ +static constexpr const char *kCodeStacktrace = "code.stacktrace"; + +} // namespace code +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_attributes.h new file mode 100644 index 00000000000..2ea7810b308 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_attributes.h @@ -0,0 +1,157 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace container +{ + +/** + * The command used to run the container (i.e. the command name). + *

        + * If using embedded credentials or sensitive data, it is recommended to remove them to prevent + * potential leakage. + */ +static constexpr const char *kContainerCommand = "container.command"; + +/** + * All the command arguments (including the command/executable itself) run by the container. + */ +static constexpr const char *kContainerCommandArgs = "container.command_args"; + +/** + * The full command run by the container as a single string representing the full command. + */ +static constexpr const char *kContainerCommandLine = "container.command_line"; + +/** + * Deprecated, use @code cpu.mode @endcode instead. + *

        + * @deprecated + * Replaced by @code cpu.mode @endcode + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kContainerCpuState = "container.cpu.state"; + +/** + * The name of the CSI (Container + * Storage Interface) plugin used by the volume.

        This can sometimes be referred to as a + * "driver" in CSI implementations. This should represent the @code name @endcode field of the + * GetPluginInfo RPC. + */ +static constexpr const char *kContainerCsiPluginName = "container.csi.plugin.name"; + +/** + * The unique volume ID returned by the CSI (Container Storage Interface) + * plugin.

        This can sometimes be referred to as a "volume handle" in CSI implementations. This + * should represent the @code Volume.volume_id @endcode field in CSI spec. + */ +static constexpr const char *kContainerCsiVolumeId = "container.csi.volume.id"; + +/** + * Container ID. Usually a UUID, as for example used to identify Docker + * containers. The UUID might be abbreviated. + */ +static constexpr const char *kContainerId = "container.id"; + +/** + * Runtime specific image identifier. Usually a hash algorithm followed by a UUID. + *

        + * Docker defines a sha256 of the image id; @code container.image.id @endcode corresponds to the + * @code Image @endcode field from the Docker container inspect API + * endpoint. K8s defines a link to the container registry repository with digest @code "imageID": + * "registry.azurecr.io + * /namespace/service/dockerfile@sha256:bdeabd40c3a8a492eaf9e8e44d0ebbb84bac7ee25ac0cf8a7159d25f62555625" + * @endcode. The ID is assigned by the container runtime and can vary in different environments. + * Consider using @code oci.manifest.digest @endcode if it is important to identify the same image + * in different environments/runtimes. + */ +static constexpr const char *kContainerImageId = "container.image.id"; + +/** + * 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. + *

        + * Docker + * and CRI + * report those under the @code RepoDigests @endcode field. + */ +static constexpr const char *kContainerImageRepoDigests = "container.image.repo_digests"; + +/** + * Container image tags. An example can be found in Docker Image + * Inspect. Should be only the @code @endcode section of the full name for example from + * @code registry.example.com/my-org/my-image: @endcode. + */ +static constexpr const char *kContainerImageTags = "container.image.tags"; + +/** + * Container labels, @code @endcode being the label name, the value being the label value. + */ +static constexpr const char *kContainerLabel = "container.label"; + +/** + * Deprecated, use @code container.label @endcode instead. + *

        + * @deprecated + * Replaced by @code container.label @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kContainerLabels = "container.labels"; + +/** + * Container name used by container runtime. + */ +static constexpr const char *kContainerName = "container.name"; + +/** + * The container runtime managing this container. + */ +static constexpr const char *kContainerRuntime = "container.runtime"; + +namespace ContainerCpuStateValues +{ +/** + * When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode + * (Windows). + */ +static constexpr const char *kUser = "user"; + +/** + * When CPU is used by the system (host OS) + */ +static constexpr const char *kSystem = "system"; + +/** + * When tasks of the cgroup are in kernel mode (Linux). When all container processes are in kernel + * mode (Windows). + */ +static constexpr const char *kKernel = "kernel"; + +} // namespace ContainerCpuStateValues + +} // namespace container +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_metrics.h new file mode 100644 index 00000000000..8fa2541b329 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_metrics.h @@ -0,0 +1,224 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace container +{ + +/** + * Total CPU time consumed + *

        + * Total CPU time consumed by the specific container on all available CPU cores + *

        + * counter + */ +static constexpr const char *kMetricContainerCpuTime = "metric.container.cpu.time"; +static constexpr const char *descrMetricContainerCpuTime = "Total CPU time consumed"; +static constexpr const char *unitMetricContainerCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricContainerCpuTime, descrMetricContainerCpuTime, + unitMetricContainerCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricContainerCpuTime, descrMetricContainerCpuTime, + unitMetricContainerCpuTime); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerCpuTime(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricContainerCpuTime, descrMetricContainerCpuTime, + unitMetricContainerCpuTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerCpuTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricContainerCpuTime, descrMetricContainerCpuTime, + unitMetricContainerCpuTime); +} + +/** + * Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + *

        + * CPU usage of the specific container on all available CPU cores, averaged over the sample window + *

        + * gauge + */ +static constexpr const char *kMetricContainerCpuUsage = "metric.container.cpu.usage"; +static constexpr const char *descrMetricContainerCpuUsage = + "Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; +static constexpr const char *unitMetricContainerCpuUsage = "{cpu}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricContainerCpuUsage, descrMetricContainerCpuUsage, + unitMetricContainerCpuUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricContainerCpuUsage, descrMetricContainerCpuUsage, + unitMetricContainerCpuUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerCpuUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricContainerCpuUsage, descrMetricContainerCpuUsage, + unitMetricContainerCpuUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerCpuUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricContainerCpuUsage, descrMetricContainerCpuUsage, + unitMetricContainerCpuUsage); +} + +/** + * Disk bytes for the container. + *

        + * The total number of bytes read/written successfully (aggregated from all disks). + *

        + * counter + */ +static constexpr const char *kMetricContainerDiskIo = "metric.container.disk.io"; +static constexpr const char *descrMetricContainerDiskIo = "Disk bytes for the container."; +static constexpr const char *unitMetricContainerDiskIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerDiskIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricContainerDiskIo, descrMetricContainerDiskIo, + unitMetricContainerDiskIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricContainerDiskIo, descrMetricContainerDiskIo, + unitMetricContainerDiskIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerDiskIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricContainerDiskIo, descrMetricContainerDiskIo, + unitMetricContainerDiskIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerDiskIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricContainerDiskIo, descrMetricContainerDiskIo, + unitMetricContainerDiskIo); +} + +/** + * Memory usage of the container. + *

        + * Memory usage of the container. + *

        + * counter + */ +static constexpr const char *kMetricContainerMemoryUsage = "metric.container.memory.usage"; +static constexpr const char *descrMetricContainerMemoryUsage = "Memory usage of the container."; +static constexpr const char *unitMetricContainerMemoryUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricContainerMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricContainerMemoryUsage, descrMetricContainerMemoryUsage, + unitMetricContainerMemoryUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricContainerMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricContainerMemoryUsage, descrMetricContainerMemoryUsage, + unitMetricContainerMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricContainerMemoryUsage, descrMetricContainerMemoryUsage, unitMetricContainerMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricContainerMemoryUsage, descrMetricContainerMemoryUsage, unitMetricContainerMemoryUsage); +} + +/** + * Network bytes for the container. + *

        + * The number of bytes sent/received on all network interfaces by the container. + *

        + * counter + */ +static constexpr const char *kMetricContainerNetworkIo = "metric.container.network.io"; +static constexpr const char *descrMetricContainerNetworkIo = "Network bytes for the container."; +static constexpr const char *unitMetricContainerNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricContainerNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricContainerNetworkIo, descrMetricContainerNetworkIo, + unitMetricContainerNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricContainerNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricContainerNetworkIo, descrMetricContainerNetworkIo, + unitMetricContainerNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerNetworkIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricContainerNetworkIo, descrMetricContainerNetworkIo, unitMetricContainerNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerNetworkIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricContainerNetworkIo, descrMetricContainerNetworkIo, unitMetricContainerNetworkIo); +} + +} // namespace container +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cpu_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cpu_attributes.h new file mode 100644 index 00000000000..b5ca637e312 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cpu_attributes.h @@ -0,0 +1,73 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace cpu +{ + +/** + * The mode of the CPU + */ +static constexpr const char *kCpuMode = "cpu.mode"; + +namespace CpuModeValues +{ +/** + * none + */ +static constexpr const char *kUser = "user"; + +/** + * none + */ +static constexpr const char *kSystem = "system"; + +/** + * none + */ +static constexpr const char *kNice = "nice"; + +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kIowait = "iowait"; + +/** + * none + */ +static constexpr const char *kInterrupt = "interrupt"; + +/** + * none + */ +static constexpr const char *kSteal = "steal"; + +/** + * none + */ +static constexpr const char *kKernel = "kernel"; + +} // namespace CpuModeValues + +} // namespace cpu +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_attributes.h new file mode 100644 index 00000000000..7c5d3304bbd --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_attributes.h @@ -0,0 +1,841 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace db +{ + +/** + * The consistency level of the query. Based on consistency values from CQL. + */ +static constexpr const char *kDbCassandraConsistencyLevel = "db.cassandra.consistency_level"; + +/** + * The data center of the coordinating node for a query. + */ +static constexpr const char *kDbCassandraCoordinatorDc = "db.cassandra.coordinator.dc"; + +/** + * 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 @endcode if the query + * was not executed speculatively. + */ +static constexpr const char *kDbCassandraSpeculativeExecutionCount = + "db.cassandra.speculative_execution_count"; + +/** + * Deprecated, use @code db.collection.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.collection.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCassandraTable = "db.cassandra.table"; + +/** + * The name of the connection pool; unique within the instrumented application. In case the + * connection pool implementation doesn't provide a name, instrumentation SHOULD use a combination + * of parameters that would make the name unique, for example, combining attributes @code + * server.address @endcode, @code server.port @endcode, and @code db.namespace @endcode, formatted + * as @code server.address:server.port/db.namespace @endcode. Instrumentations that generate + * connection pool name following different patterns SHOULD document it. + */ +static constexpr const char *kDbClientConnectionPoolName = "db.client.connection.pool.name"; + +/** + * The state of a connection in the pool + */ +static constexpr const char *kDbClientConnectionState = "db.client.connection.state"; + +/** + * Deprecated, use @code db.client.connection.pool.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.pool.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; + +/** + * Deprecated, use @code db.client.connection.state @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.state @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; + +/** + * The name of a collection (table, container) within the database. + *

        + * It is RECOMMENDED to capture the value as provided by the application without attempting to do + * any case normalization. If the collection name is parsed from the query text, it SHOULD be the + * first collection name found in the query and it SHOULD match the value provided in the query text + * including any schema and database name prefix. For batch operations, if the individual operations + * are known to have the same collection name then that collection name SHOULD be used, otherwise + * @code db.collection.name @endcode SHOULD NOT be captured. This attribute has stability level + * RELEASE CANDIDATE. + */ +static constexpr const char *kDbCollectionName = "db.collection.name"; + +/** + * Deprecated, use @code server.address @endcode, @code server.port @endcode attributes instead. + *

        + * @deprecated + * Replaced by @code server.address @endcode and @code server.port @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbConnectionString = "db.connection_string"; + +/** + * Unique Cosmos client instance id. + */ +static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; + +/** + * Cosmos client connection mode. + */ +static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; + +/** + * Deprecated, use @code db.collection.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.collection.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; + +/** + * Cosmos DB Operation Type. + */ +static constexpr const char *kDbCosmosdbOperationType = "db.cosmosdb.operation_type"; + +/** + * RU consumed for that operation + */ +static constexpr const char *kDbCosmosdbRequestCharge = "db.cosmosdb.request_charge"; + +/** + * Request payload size in bytes + */ +static constexpr const char *kDbCosmosdbRequestContentLength = "db.cosmosdb.request_content_length"; + +/** + * Deprecated, use @code db.response.status_code @endcode instead. + *

        + * @deprecated + * Replaced by @code db.response.status_code @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; + +/** + * Cosmos DB sub status code. + */ +static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; + +/** + * Deprecated, use @code db.namespace @endcode instead. + *

        + * @deprecated + * Replaced by @code db.namespace @endcode. + */ +OPENTELEMETRY_DEPRECATED +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"; + +/** + * A dynamic value in the url path. + *

        + * Many Elasticsearch url paths allow dynamic values. These SHOULD be recorded in span attributes in + * the format @code db.elasticsearch.path_parts. @endcode, where @code @endcode is the + * url path part name. The implementation SHOULD reference the elasticsearch + * schema in order to map the path part values to their names. + */ +static constexpr const char *kDbElasticsearchPathParts = "db.elasticsearch.path_parts"; + +/** + * Deprecated, no general replacement at this time. For Elasticsearch, use @code + * db.elasticsearch.node.name @endcode instead.

        + * @deprecated + * Deprecated, no general replacement at this time. For Elasticsearch, use @code + * db.elasticsearch.node.name @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbInstanceId = "db.instance.id"; + +/** + * Removed, no replacement at this time. + *

        + * @deprecated + * Removed as not used. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; + +/** + * Deprecated, use @code db.collection.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.collection.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbMongodbCollection = "db.mongodb.collection"; + +/** + * Deprecated, SQL Server instance is now populated as a part of @code db.namespace @endcode + * attribute.

        + * @deprecated + * Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbMssqlInstanceName = "db.mssql.instance_name"; + +/** + * Deprecated, use @code db.namespace @endcode instead. + *

        + * @deprecated + * Replaced by @code db.namespace @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbName = "db.name"; + +/** + * The name of the database, fully qualified within the server address and port. + *

        + * If a database system has multiple namespace components, they SHOULD be concatenated (potentially + * using database system specific conventions) from most general to most specific namespace + * component, and more specific namespaces SHOULD NOT be captured without the more general + * namespaces, to ensure that "startswith" queries for the more general namespaces will be valid. + * Semantic conventions for individual database systems SHOULD document what @code db.namespace + * @endcode means in the context of that system. It is RECOMMENDED to capture the value as provided + * by the application without attempting to do any case normalization. This attribute has stability + * level RELEASE CANDIDATE. + */ +static constexpr const char *kDbNamespace = "db.namespace"; + +/** + * Deprecated, use @code db.operation.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.operation.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbOperation = "db.operation"; + +/** + * The number of queries included in a batch operation. + *

        + * Operations are only considered batches when they contain two or more operations, and so @code + * db.operation.batch.size @endcode SHOULD never be @code 1 @endcode. This attribute has stability + * level RELEASE CANDIDATE. + */ +static constexpr const char *kDbOperationBatchSize = "db.operation.batch.size"; + +/** + * The name of the operation or command being executed. + *

        + * It is RECOMMENDED to capture the value as provided by the application without attempting to do + * any case normalization. If the operation name is parsed from the query text, it SHOULD be the + * first operation name found in the query. For batch operations, if the individual operations are + * known to have the same operation name then that operation name SHOULD be used prepended by @code + * BATCH @endcode, otherwise @code db.operation.name @endcode SHOULD be @code BATCH @endcode or + * some other database system specific term if more applicable. This attribute has stability level + * RELEASE CANDIDATE. + */ +static constexpr const char *kDbOperationName = "db.operation.name"; + +/** + * A query parameter used in @code db.query.text @endcode, with @code @endcode being the + * parameter name, and the attribute value being a string representation of the parameter value.

        + * Query parameters should only be captured when @code db.query.text @endcode is parameterized with + * placeholders. If a parameter has no name and instead is referenced only by index, then @code + * @endcode SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. + */ +static constexpr const char *kDbQueryParameter = "db.query.parameter"; + +/** + * The database query being executed. + *

        + * For sanitization see Sanitization of @code + * db.query.text @endcode. For batch operations, if the individual operations are known to have + * the same query text then that query text SHOULD be used, otherwise all of the individual query + * texts SHOULD be concatenated with separator @code ; @endcode or some other database system + * specific separator if more applicable. Even though parameterized query text can potentially have + * sensitive data, by using a parameterized query the user is giving a strong signal that any + * sensitive data will be passed as parameter values, and the benefit to observability of capturing + * the static part of the query text by default outweighs the risk. This attribute has stability + * level RELEASE CANDIDATE. + */ +static constexpr const char *kDbQueryText = "db.query.text"; + +/** + * Deprecated, use @code db.namespace @endcode instead. + *

        + * @deprecated + * Replaced by @code db.namespace @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; + +/** + * Database response status code. + *

        + * The status code returned by the database. Usually it represents an error code, but may also + * represent partial success, warning, or differentiate between various types of successful + * outcomes. Semantic conventions for individual database systems SHOULD document what @code + * db.response.status_code @endcode means in the context of that system. This attribute has + * stability level RELEASE CANDIDATE. + */ +static constexpr const char *kDbResponseStatusCode = "db.response.status_code"; + +/** + * Deprecated, use @code db.collection.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.collection.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbSqlTable = "db.sql.table"; + +/** + * The database statement being executed. + *

        + * @deprecated + * Replaced by @code db.query.text @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbStatement = "db.statement"; + +/** + * The database management system (DBMS) product as identified by the client instrumentation. + *

        + * The actual DBMS may differ from the one identified by the client. For example, when using + * PostgreSQL client libraries to connect to a CockroachDB, the @code db.system @endcode is set to + * @code postgresql @endcode based on the instrumentation's best knowledge. This attribute has + * stability level RELEASE CANDIDATE. + */ +static constexpr const char *kDbSystem = "db.system"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * No replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbUser = "db.user"; + +namespace DbCassandraConsistencyLevelValues +{ +/** + * none + */ +static constexpr const char *kAll = "all"; + +/** + * none + */ +static constexpr const char *kEachQuorum = "each_quorum"; + +/** + * none + */ +static constexpr const char *kQuorum = "quorum"; + +/** + * none + */ +static constexpr const char *kLocalQuorum = "local_quorum"; + +/** + * none + */ +static constexpr const char *kOne = "one"; + +/** + * none + */ +static constexpr const char *kTwo = "two"; + +/** + * none + */ +static constexpr const char *kThree = "three"; + +/** + * none + */ +static constexpr const char *kLocalOne = "local_one"; + +/** + * none + */ +static constexpr const char *kAny = "any"; + +/** + * none + */ +static constexpr const char *kSerial = "serial"; + +/** + * none + */ +static constexpr const char *kLocalSerial = "local_serial"; + +} // namespace DbCassandraConsistencyLevelValues + +namespace DbClientConnectionStateValues +{ +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kUsed = "used"; + +} // namespace DbClientConnectionStateValues + +namespace DbClientConnectionsStateValues +{ +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kUsed = "used"; + +} // namespace DbClientConnectionsStateValues + +namespace DbCosmosdbConnectionModeValues +{ +/** + * Gateway (HTTP) connections mode + */ +static constexpr const char *kGateway = "gateway"; + +/** + * Direct connection. + */ +static constexpr const char *kDirect = "direct"; + +} // namespace DbCosmosdbConnectionModeValues + +namespace DbCosmosdbOperationTypeValues +{ +/** + * none + */ +static constexpr const char *kBatch = "batch"; + +/** + * none + */ +static constexpr const char *kCreate = "create"; + +/** + * none + */ +static constexpr const char *kDelete = "delete"; + +/** + * none + */ +static constexpr const char *kExecute = "execute"; + +/** + * none + */ +static constexpr const char *kExecuteJavascript = "execute_javascript"; + +/** + * none + */ +static constexpr const char *kInvalid = "invalid"; + +/** + * none + */ +static constexpr const char *kHead = "head"; + +/** + * none + */ +static constexpr const char *kHeadFeed = "head_feed"; + +/** + * none + */ +static constexpr const char *kPatch = "patch"; + +/** + * none + */ +static constexpr const char *kQuery = "query"; + +/** + * none + */ +static constexpr const char *kQueryPlan = "query_plan"; + +/** + * none + */ +static constexpr const char *kRead = "read"; + +/** + * none + */ +static constexpr const char *kReadFeed = "read_feed"; + +/** + * none + */ +static constexpr const char *kReplace = "replace"; + +/** + * none + */ +static constexpr const char *kUpsert = "upsert"; + +} // namespace DbCosmosdbOperationTypeValues + +namespace DbSystemValues +{ +/** + * Some other SQL database. Fallback only. See notes. + */ +static constexpr const char *kOtherSql = "other_sql"; + +/** + * Adabas (Adaptable Database System) + */ +static constexpr const char *kAdabas = "adabas"; + +/** + * Deprecated, use @code intersystems_cache @endcode instead. + *

        + * @deprecated + * Replaced by @code intersystems_cache @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kCache = "cache"; + +/** + * InterSystems Caché + */ +static constexpr const char *kIntersystemsCache = "intersystems_cache"; + +/** + * Apache Cassandra + */ +static constexpr const char *kCassandra = "cassandra"; + +/** + * ClickHouse + */ +static constexpr const char *kClickhouse = "clickhouse"; + +/** + * Deprecated, use @code other_sql @endcode instead. + *

        + * @deprecated + * Replaced by @code other_sql @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kCloudscape = "cloudscape"; + +/** + * CockroachDB + */ +static constexpr const char *kCockroachdb = "cockroachdb"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * Removed. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kColdfusion = "coldfusion"; + +/** + * Microsoft Azure Cosmos DB + */ +static constexpr const char *kCosmosdb = "cosmosdb"; + +/** + * Couchbase + */ +static constexpr const char *kCouchbase = "couchbase"; + +/** + * CouchDB + */ +static constexpr const char *kCouchdb = "couchdb"; + +/** + * IBM Db2 + */ +static constexpr const char *kDb2 = "db2"; + +/** + * Apache Derby + */ +static constexpr const char *kDerby = "derby"; + +/** + * Amazon DynamoDB + */ +static constexpr const char *kDynamodb = "dynamodb"; + +/** + * EnterpriseDB + */ +static constexpr const char *kEdb = "edb"; + +/** + * Elasticsearch + */ +static constexpr const char *kElasticsearch = "elasticsearch"; + +/** + * FileMaker + */ +static constexpr const char *kFilemaker = "filemaker"; + +/** + * Firebird + */ +static constexpr const char *kFirebird = "firebird"; + +/** + * Deprecated, use @code other_sql @endcode instead. + *

        + * @deprecated + * Replaced by @code other_sql @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kFirstsql = "firstsql"; + +/** + * Apache Geode + */ +static constexpr const char *kGeode = "geode"; + +/** + * H2 + */ +static constexpr const char *kH2 = "h2"; + +/** + * SAP HANA + */ +static constexpr const char *kHanadb = "hanadb"; + +/** + * Apache HBase + */ +static constexpr const char *kHbase = "hbase"; + +/** + * Apache Hive + */ +static constexpr const char *kHive = "hive"; + +/** + * HyperSQL DataBase + */ +static constexpr const char *kHsqldb = "hsqldb"; + +/** + * InfluxDB + */ +static constexpr const char *kInfluxdb = "influxdb"; + +/** + * Informix + */ +static constexpr const char *kInformix = "informix"; + +/** + * Ingres + */ +static constexpr const char *kIngres = "ingres"; + +/** + * InstantDB + */ +static constexpr const char *kInstantdb = "instantdb"; + +/** + * InterBase + */ +static constexpr const char *kInterbase = "interbase"; + +/** + * MariaDB (This value has stability level RELEASE CANDIDATE) + */ +static constexpr const char *kMariadb = "mariadb"; + +/** + * SAP MaxDB + */ +static constexpr const char *kMaxdb = "maxdb"; + +/** + * Memcached + */ +static constexpr const char *kMemcached = "memcached"; + +/** + * MongoDB + */ +static constexpr const char *kMongodb = "mongodb"; + +/** + * Microsoft SQL Server (This value has stability level RELEASE CANDIDATE) + */ +static constexpr const char *kMssql = "mssql"; + +/** + * Deprecated, Microsoft SQL Server Compact is discontinued. + *

        + * @deprecated + * Removed, use @code other_sql @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMssqlcompact = "mssqlcompact"; + +/** + * MySQL (This value has stability level RELEASE CANDIDATE) + */ +static constexpr const char *kMysql = "mysql"; + +/** + * Neo4j + */ +static constexpr const char *kNeo4j = "neo4j"; + +/** + * Netezza + */ +static constexpr const char *kNetezza = "netezza"; + +/** + * OpenSearch + */ +static constexpr const char *kOpensearch = "opensearch"; + +/** + * Oracle Database + */ +static constexpr const char *kOracle = "oracle"; + +/** + * Pervasive PSQL + */ +static constexpr const char *kPervasive = "pervasive"; + +/** + * PointBase + */ +static constexpr const char *kPointbase = "pointbase"; + +/** + * PostgreSQL (This value has stability level RELEASE CANDIDATE) + */ +static constexpr const char *kPostgresql = "postgresql"; + +/** + * Progress Database + */ +static constexpr const char *kProgress = "progress"; + +/** + * Redis + */ +static constexpr const char *kRedis = "redis"; + +/** + * Amazon Redshift + */ +static constexpr const char *kRedshift = "redshift"; + +/** + * Cloud Spanner + */ +static constexpr const char *kSpanner = "spanner"; + +/** + * SQLite + */ +static constexpr const char *kSqlite = "sqlite"; + +/** + * Sybase + */ +static constexpr const char *kSybase = "sybase"; + +/** + * Teradata + */ +static constexpr const char *kTeradata = "teradata"; + +/** + * Trino + */ +static constexpr const char *kTrino = "trino"; + +/** + * Vertica + */ +static constexpr const char *kVertica = "vertica"; + +} // namespace DbSystemValues + +} // namespace db +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_metrics.h new file mode 100644 index 00000000000..d3dd52190e5 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_metrics.h @@ -0,0 +1,816 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace db +{ + +/** + * The number of connections that are currently in state described by the @code state @endcode + * attribute

        updowncounter + */ +static constexpr const char *kMetricDbClientConnectionCount = "metric.db.client.connection.count"; +static constexpr const char *descrMetricDbClientConnectionCount = + "The number of connections that are currently in state described by the `state` attribute"; +static constexpr const char *unitMetricDbClientConnectionCount = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionCount, + descrMetricDbClientConnectionCount, + unitMetricDbClientConnectionCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionCount, + descrMetricDbClientConnectionCount, + unitMetricDbClientConnectionCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionCount, + descrMetricDbClientConnectionCount, + unitMetricDbClientConnectionCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionCount, + descrMetricDbClientConnectionCount, + unitMetricDbClientConnectionCount); +} + +/** + * The time it took to create a new connection + *

        + * histogram + */ +static constexpr const char *kMetricDbClientConnectionCreateTime = + "metric.db.client.connection.create_time"; +static constexpr const char *descrMetricDbClientConnectionCreateTime = + "The time it took to create a new connection"; +static constexpr const char *unitMetricDbClientConnectionCreateTime = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionCreateTime(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionCreateTime, + descrMetricDbClientConnectionCreateTime, + unitMetricDbClientConnectionCreateTime); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionCreateTime(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionCreateTime, + descrMetricDbClientConnectionCreateTime, + unitMetricDbClientConnectionCreateTime); +} + +/** + * The maximum number of idle open connections allowed + *

        + * updowncounter + */ +static constexpr const char *kMetricDbClientConnectionIdleMax = + "metric.db.client.connection.idle.max"; +static constexpr const char *descrMetricDbClientConnectionIdleMax = + "The maximum number of idle open connections allowed"; +static constexpr const char *unitMetricDbClientConnectionIdleMax = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionIdleMax(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionIdleMax, + descrMetricDbClientConnectionIdleMax, + unitMetricDbClientConnectionIdleMax); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionIdleMax(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionIdleMax, + descrMetricDbClientConnectionIdleMax, + unitMetricDbClientConnectionIdleMax); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionIdleMax(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionIdleMax, + descrMetricDbClientConnectionIdleMax, + unitMetricDbClientConnectionIdleMax); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionIdleMax(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionIdleMax, + descrMetricDbClientConnectionIdleMax, + unitMetricDbClientConnectionIdleMax); +} + +/** + * The minimum number of idle open connections allowed + *

        + * updowncounter + */ +static constexpr const char *kMetricDbClientConnectionIdleMin = + "metric.db.client.connection.idle.min"; +static constexpr const char *descrMetricDbClientConnectionIdleMin = + "The minimum number of idle open connections allowed"; +static constexpr const char *unitMetricDbClientConnectionIdleMin = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionIdleMin(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionIdleMin, + descrMetricDbClientConnectionIdleMin, + unitMetricDbClientConnectionIdleMin); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionIdleMin(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionIdleMin, + descrMetricDbClientConnectionIdleMin, + unitMetricDbClientConnectionIdleMin); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionIdleMin(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionIdleMin, + descrMetricDbClientConnectionIdleMin, + unitMetricDbClientConnectionIdleMin); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionIdleMin(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionIdleMin, + descrMetricDbClientConnectionIdleMin, + unitMetricDbClientConnectionIdleMin); +} + +/** + * The maximum number of open connections allowed + *

        + * updowncounter + */ +static constexpr const char *kMetricDbClientConnectionMax = "metric.db.client.connection.max"; +static constexpr const char *descrMetricDbClientConnectionMax = + "The maximum number of open connections allowed"; +static constexpr const char *unitMetricDbClientConnectionMax = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionMax(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionMax, + descrMetricDbClientConnectionMax, + unitMetricDbClientConnectionMax); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionMax(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionMax, + descrMetricDbClientConnectionMax, + unitMetricDbClientConnectionMax); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionMax(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionMax, + descrMetricDbClientConnectionMax, + unitMetricDbClientConnectionMax); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionMax(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionMax, + descrMetricDbClientConnectionMax, + unitMetricDbClientConnectionMax); +} + +/** + * The number of current pending requests for an open connection + *

        + * updowncounter + */ +static constexpr const char *kMetricDbClientConnectionPendingRequests = + "metric.db.client.connection.pending_requests"; +static constexpr const char *descrMetricDbClientConnectionPendingRequests = + "The number of current pending requests for an open connection"; +static constexpr const char *unitMetricDbClientConnectionPendingRequests = "{request}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionPendingRequests(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionPendingRequests, + descrMetricDbClientConnectionPendingRequests, + unitMetricDbClientConnectionPendingRequests); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionPendingRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionPendingRequests, + descrMetricDbClientConnectionPendingRequests, + unitMetricDbClientConnectionPendingRequests); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionPendingRequests(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionPendingRequests, + descrMetricDbClientConnectionPendingRequests, + unitMetricDbClientConnectionPendingRequests); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionPendingRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionPendingRequests, + descrMetricDbClientConnectionPendingRequests, + unitMetricDbClientConnectionPendingRequests); +} + +/** + * The number of connection timeouts that have occurred trying to obtain a connection from the pool + *

        + * counter + */ +static constexpr const char *kMetricDbClientConnectionTimeouts = + "metric.db.client.connection.timeouts"; +static constexpr const char *descrMetricDbClientConnectionTimeouts = + "The number of connection timeouts that have occurred trying to obtain a connection from the " + "pool"; +static constexpr const char *unitMetricDbClientConnectionTimeouts = "{timeout}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionTimeouts(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricDbClientConnectionTimeouts, + descrMetricDbClientConnectionTimeouts, + unitMetricDbClientConnectionTimeouts); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionTimeouts(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricDbClientConnectionTimeouts, + descrMetricDbClientConnectionTimeouts, + unitMetricDbClientConnectionTimeouts); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionTimeouts(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricDbClientConnectionTimeouts, + descrMetricDbClientConnectionTimeouts, + unitMetricDbClientConnectionTimeouts); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionTimeouts(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricDbClientConnectionTimeouts, + descrMetricDbClientConnectionTimeouts, + unitMetricDbClientConnectionTimeouts); +} + +/** + * The time between borrowing a connection and returning it to the pool + *

        + * histogram + */ +static constexpr const char *kMetricDbClientConnectionUseTime = + "metric.db.client.connection.use_time"; +static constexpr const char *descrMetricDbClientConnectionUseTime = + "The time between borrowing a connection and returning it to the pool"; +static constexpr const char *unitMetricDbClientConnectionUseTime = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionUseTime(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionUseTime, + descrMetricDbClientConnectionUseTime, + unitMetricDbClientConnectionUseTime); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionUseTime(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionUseTime, + descrMetricDbClientConnectionUseTime, + unitMetricDbClientConnectionUseTime); +} + +/** + * The time it took to obtain an open connection from the pool + *

        + * histogram + */ +static constexpr const char *kMetricDbClientConnectionWaitTime = + "metric.db.client.connection.wait_time"; +static constexpr const char *descrMetricDbClientConnectionWaitTime = + "The time it took to obtain an open connection from the pool"; +static constexpr const char *unitMetricDbClientConnectionWaitTime = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionWaitTime(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionWaitTime, + descrMetricDbClientConnectionWaitTime, + unitMetricDbClientConnectionWaitTime); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionWaitTime(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionWaitTime, + descrMetricDbClientConnectionWaitTime, + unitMetricDbClientConnectionWaitTime); +} + +/** + * Deprecated, use @code db.client.connection.create_time @endcode instead. Note: the unit also + * changed from @code ms @endcode to @code s @endcode.

        + * @deprecated + * Replaced by @code db.client.connection.create_time @endcode. Note: the unit also changed from + * @code ms @endcode to @code s @endcode.

        histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsCreateTimeDeprecated = + "metric.db.client.connections.create_time.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsCreateTimeDeprecated = + "Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from " + "`ms` to `s`."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsCreateTimeDeprecated = "ms"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsCreateTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsCreateTimeDeprecated, + descrMetricDbClientConnectionsCreateTimeDeprecated, + unitMetricDbClientConnectionsCreateTimeDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsCreateTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsCreateTimeDeprecated, + descrMetricDbClientConnectionsCreateTimeDeprecated, + unitMetricDbClientConnectionsCreateTimeDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.idle.max @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.idle.max @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsIdleMaxDeprecated = + "metric.db.client.connections.idle.max.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsIdleMaxDeprecated = + "Deprecated, use `db.client.connection.idle.max` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsIdleMaxDeprecated = "{connection}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, + descrMetricDbClientConnectionsIdleMaxDeprecated, + unitMetricDbClientConnectionsIdleMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, + descrMetricDbClientConnectionsIdleMaxDeprecated, + unitMetricDbClientConnectionsIdleMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, + descrMetricDbClientConnectionsIdleMaxDeprecated, + unitMetricDbClientConnectionsIdleMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsIdleMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsIdleMaxDeprecated, + descrMetricDbClientConnectionsIdleMaxDeprecated, + unitMetricDbClientConnectionsIdleMaxDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.idle.min @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.idle.min @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsIdleMinDeprecated = + "metric.db.client.connections.idle.min.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsIdleMinDeprecated = + "Deprecated, use `db.client.connection.idle.min` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsIdleMinDeprecated = "{connection}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, + descrMetricDbClientConnectionsIdleMinDeprecated, + unitMetricDbClientConnectionsIdleMinDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, + descrMetricDbClientConnectionsIdleMinDeprecated, + unitMetricDbClientConnectionsIdleMinDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, + descrMetricDbClientConnectionsIdleMinDeprecated, + unitMetricDbClientConnectionsIdleMinDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsIdleMinDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsIdleMinDeprecated, + descrMetricDbClientConnectionsIdleMinDeprecated, + unitMetricDbClientConnectionsIdleMinDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.max @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.max @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsMaxDeprecated = + "metric.db.client.connections.max.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsMaxDeprecated = + "Deprecated, use `db.client.connection.max` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsMaxDeprecated = "{connection}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsMaxDeprecated, + descrMetricDbClientConnectionsMaxDeprecated, + unitMetricDbClientConnectionsMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, + descrMetricDbClientConnectionsMaxDeprecated, + unitMetricDbClientConnectionsMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, + descrMetricDbClientConnectionsMaxDeprecated, + unitMetricDbClientConnectionsMaxDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsMaxDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsMaxDeprecated, + descrMetricDbClientConnectionsMaxDeprecated, + unitMetricDbClientConnectionsMaxDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.pending_requests @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.pending_requests @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsPendingRequestsDeprecated = + "metric.db.client.connections.pending_requests.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsPendingRequestsDeprecated = + "Deprecated, use `db.client.connection.pending_requests` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsPendingRequestsDeprecated = "{request}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsPendingRequestsDeprecated, + descrMetricDbClientConnectionsPendingRequestsDeprecated, + unitMetricDbClientConnectionsPendingRequestsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsPendingRequestsDeprecated, + descrMetricDbClientConnectionsPendingRequestsDeprecated, + unitMetricDbClientConnectionsPendingRequestsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricDbClientConnectionsPendingRequestsDeprecated, + descrMetricDbClientConnectionsPendingRequestsDeprecated, + unitMetricDbClientConnectionsPendingRequestsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsPendingRequestsDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricDbClientConnectionsPendingRequestsDeprecated, + descrMetricDbClientConnectionsPendingRequestsDeprecated, + unitMetricDbClientConnectionsPendingRequestsDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.timeouts @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.timeouts @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsTimeoutsDeprecated = + "metric.db.client.connections.timeouts.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsTimeoutsDeprecated = + "Deprecated, use `db.client.connection.timeouts` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsTimeoutsDeprecated = "{timeout}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricDbClientConnectionsTimeoutsDeprecated, + descrMetricDbClientConnectionsTimeoutsDeprecated, + unitMetricDbClientConnectionsTimeoutsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricDbClientConnectionsTimeoutsDeprecated, + descrMetricDbClientConnectionsTimeoutsDeprecated, + unitMetricDbClientConnectionsTimeoutsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricDbClientConnectionsTimeoutsDeprecated, + descrMetricDbClientConnectionsTimeoutsDeprecated, + unitMetricDbClientConnectionsTimeoutsDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsTimeoutsDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricDbClientConnectionsTimeoutsDeprecated, + descrMetricDbClientConnectionsTimeoutsDeprecated, + unitMetricDbClientConnectionsTimeoutsDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.count @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.count @endcode. + *

        + * updowncounter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsCountDeprecated = + "metric.db.client.connections.count.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsCountDeprecated = + "Deprecated, use `db.client.connection.count` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsCountDeprecated = "{connection}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricDbClientConnectionsCountDeprecated, + descrMetricDbClientConnectionsCountDeprecated, + unitMetricDbClientConnectionsCountDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricDbClientConnectionsCountDeprecated, + descrMetricDbClientConnectionsCountDeprecated, + unitMetricDbClientConnectionsCountDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricDbClientConnectionsCountDeprecated, + descrMetricDbClientConnectionsCountDeprecated, + unitMetricDbClientConnectionsCountDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricDbClientConnectionsCountDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricDbClientConnectionsCountDeprecated, + descrMetricDbClientConnectionsCountDeprecated, + unitMetricDbClientConnectionsCountDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.use_time @endcode instead. Note: the unit also changed + * from @code ms @endcode to @code s @endcode.

        + * @deprecated + * Replaced by @code db.client.connection.use_time @endcode. Note: the unit also changed from @code + * ms @endcode to @code s @endcode.

        histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsUseTimeDeprecated = + "metric.db.client.connections.use_time.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsUseTimeDeprecated = + "Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from " + "`ms` to `s`."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsUseTimeDeprecated = "ms"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsUseTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsUseTimeDeprecated, + descrMetricDbClientConnectionsUseTimeDeprecated, + unitMetricDbClientConnectionsUseTimeDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsUseTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsUseTimeDeprecated, + descrMetricDbClientConnectionsUseTimeDeprecated, + unitMetricDbClientConnectionsUseTimeDeprecated); +} + +/** + * Deprecated, use @code db.client.connection.wait_time @endcode instead. Note: the unit also + * changed from @code ms @endcode to @code s @endcode.

        + * @deprecated + * Replaced by @code db.client.connection.wait_time @endcode. Note: the unit also changed from @code + * ms @endcode to @code s @endcode.

        histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricDbClientConnectionsWaitTimeDeprecated = + "metric.db.client.connections.wait_time.deprecated"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricDbClientConnectionsWaitTimeDeprecated = + "Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from " + "`ms` to `s`."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricDbClientConnectionsWaitTimeDeprecated = "ms"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientConnectionsWaitTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientConnectionsWaitTimeDeprecated, + descrMetricDbClientConnectionsWaitTimeDeprecated, + unitMetricDbClientConnectionsWaitTimeDeprecated); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientConnectionsWaitTimeDeprecated(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientConnectionsWaitTimeDeprecated, + descrMetricDbClientConnectionsWaitTimeDeprecated, + unitMetricDbClientConnectionsWaitTimeDeprecated); +} + +/** + * Duration of database client operations. + *

        + * Batch operations SHOULD be recorded as a single operation. + *

        + * histogram + */ +static constexpr const char *kMetricDbClientOperationDuration = + "metric.db.client.operation.duration"; +static constexpr const char *descrMetricDbClientOperationDuration = + "Duration of database client operations."; +static constexpr const char *unitMetricDbClientOperationDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDbClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDbClientOperationDuration, + descrMetricDbClientOperationDuration, + unitMetricDbClientOperationDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricDbClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDbClientOperationDuration, + descrMetricDbClientOperationDuration, + unitMetricDbClientOperationDuration); +} + +} // namespace db +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/deployment_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/deployment_attributes.h new file mode 100644 index 00000000000..9c4594b7f3b --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/deployment_attributes.h @@ -0,0 +1,76 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace deployment +{ + +/** + * 'Deprecated, use @code deployment.environment.name @endcode instead.' + *

        + * @deprecated + * Deprecated, use @code deployment.environment.name @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDeploymentEnvironment = "deployment.environment"; + +/** + * Name of the deployment + * environment (aka deployment tier).

        + * @code deployment.environment.name @endcode does not affect the uniqueness constraints defined + * through the @code service.namespace @endcode, @code service.name @endcode and @code + * service.instance.id @endcode resource attributes. This implies that resources carrying the + * following attribute combinations MUST be considered to be identifying the same service:

          + *
        • @code service.name=frontend @endcode, @code deployment.environment.name=production + * @endcode
        • @code service.name=frontend @endcode, @code deployment.environment.name=staging + * @endcode.
        • + *
        + */ +static constexpr const char *kDeploymentEnvironmentName = "deployment.environment.name"; + +/** + * The id of the deployment. + */ +static constexpr const char *kDeploymentId = "deployment.id"; + +/** + * The name of the deployment. + */ +static constexpr const char *kDeploymentName = "deployment.name"; + +/** + * The status of the deployment. + */ +static constexpr const char *kDeploymentStatus = "deployment.status"; + +namespace DeploymentStatusValues +{ +/** + * failed + */ +static constexpr const char *kFailed = "failed"; + +/** + * succeeded + */ +static constexpr const char *kSucceeded = "succeeded"; + +} // namespace DeploymentStatusValues + +} // namespace deployment +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/destination_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/destination_attributes.h new file mode 100644 index 00000000000..5069fc03b7d --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/destination_attributes.h @@ -0,0 +1,37 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace destination +{ + +/** + * Destination address - domain name if available without reverse DNS lookup; otherwise, IP address + * or Unix domain socket name.

        When observed from the source side, and when communicating + * through an intermediary, @code destination.address @endcode SHOULD represent the destination + * address behind any intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kDestinationAddress = "destination.address"; + +/** + * Destination port number + */ +static constexpr const char *kDestinationPort = "destination.port"; + +} // namespace destination +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/device_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/device_attributes.h new file mode 100644 index 00000000000..c2c80f5fd2f --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/device_attributes.h @@ -0,0 +1,66 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace device +{ + +/** + * A unique identifier representing the device + *

        + * The device identifier MUST only be defined using the values outlined below. This value is not an + * advertising identifier and MUST NOT be used as such. On iOS (Swift or Objective-C), this value + * MUST be equal to the vendor + * identifier. On Android (Java or Kotlin), this value MUST be equal to the Firebase + * Installation ID or a globally unique UUID which is persisted across sessions in your application. + * More information can be found here on best practices + * and exact implementation details. Caution should be taken when storing personal data or anything + * which can identify a user. GDPR and data protection laws may apply, ensure you do your own due + * diligence. + */ +static constexpr const char *kDeviceId = "device.id"; + +/** + * The name of the device manufacturer + *

        + * The Android OS provides this field via Build. iOS apps + * SHOULD hardcode the value @code Apple @endcode. + */ +static constexpr const char *kDeviceManufacturer = "device.manufacturer"; + +/** + * The model identifier for the device + *

        + * It's recommended this value represents a machine-readable version of the model identifier rather + * than the market or consumer-friendly name of the device. + */ +static constexpr const char *kDeviceModelIdentifier = "device.model.identifier"; + +/** + * The marketing name for the device model + *

        + * It's recommended this value represents a human-readable version of the device model rather than a + * machine-readable alternative. + */ +static constexpr const char *kDeviceModelName = "device.model.name"; + +} // namespace device +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/disk_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/disk_attributes.h new file mode 100644 index 00000000000..ff938a96121 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/disk_attributes.h @@ -0,0 +1,43 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace disk +{ + +/** + * The disk IO operation direction. + */ +static constexpr const char *kDiskIoDirection = "disk.io.direction"; + +namespace DiskIoDirectionValues +{ +/** + * none + */ +static constexpr const char *kRead = "read"; + +/** + * none + */ +static constexpr const char *kWrite = "write"; + +} // namespace DiskIoDirectionValues + +} // namespace disk +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/dns_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/dns_attributes.h new file mode 100644 index 00000000000..b835e2a73ad --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/dns_attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace dns +{ + +/** + * The name being queried. + *

        + * If the name field contains non-printable characters (below 32 or above 126), those characters + * should be represented as escaped base 10 integers (\DDD). Back slashes and quotes should be + * escaped. Tabs, carriage returns, and line feeds should be converted to \t, \r, and \n + * respectively. + */ +static constexpr const char *kDnsQuestionName = "dns.question.name"; + +} // namespace dns +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/dns_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/dns_metrics.h new file mode 100644 index 00000000000..7f3915870bd --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/dns_metrics.h @@ -0,0 +1,49 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace dns +{ + +/** + * Measures the time taken to perform a DNS lookup. + *

        + * histogram + */ +static constexpr const char *kMetricDnsLookupDuration = "metric.dns.lookup.duration"; +static constexpr const char *descrMetricDnsLookupDuration = + "Measures the time taken to perform a DNS lookup."; +static constexpr const char *unitMetricDnsLookupDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricDnsLookupDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricDnsLookupDuration, descrMetricDnsLookupDuration, + unitMetricDnsLookupDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricDnsLookupDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricDnsLookupDuration, descrMetricDnsLookupDuration, + unitMetricDnsLookupDuration); +} + +} // namespace dns +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/enduser_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/enduser_attributes.h new file mode 100644 index 00000000000..217d5dd414b --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/enduser_attributes.h @@ -0,0 +1,51 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace enduser +{ + +/** + * Deprecated, use @code user.id @endcode instead. + *

        + * @deprecated + * Replaced by @code user.id @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserId = "enduser.id"; + +/** + * Deprecated, use @code user.roles @endcode instead. + *

        + * @deprecated + * Replaced by @code user.roles @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserRole = "enduser.role"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * Removed. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kEnduserScope = "enduser.scope"; + +} // namespace enduser +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/error_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/error_attributes.h new file mode 100644 index 00000000000..1b711ff112d --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/error_attributes.h @@ -0,0 +1,57 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace error +{ + +/** + * Describes a class of error the operation ended with. + *

        + * The @code error.type @endcode SHOULD be predictable, and SHOULD have low cardinality. + *

        + * When @code error.type @endcode is set to a type (e.g., an exception type), its + * canonical class name identifying the type within the artifact SHOULD be used. + *

        + * Instrumentations SHOULD document the list of errors they report. + *

        + * The cardinality of @code error.type @endcode within one instrumentation library SHOULD be low. + * Telemetry consumers that aggregate data from multiple instrumentation libraries and applications + * should be prepared for @code error.type @endcode 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 + * @endcode.

        If a specific domain defines its own set of error identifiers (such as HTTP or gRPC + * status codes), it's RECOMMENDED to:

        • Use a domain-specific attribute
        • Set + * @code error.type @endcode to capture all errors, regardless of whether they are defined within + * the domain-specific set or not.
        • + *
        + */ +static constexpr const char *kErrorType = "error.type"; + +namespace ErrorTypeValues +{ +/** + * A fallback error value to be used when the instrumentation doesn't define a custom value. + */ +static constexpr const char *kOther = "_OTHER"; + +} // namespace ErrorTypeValues + +} // namespace error +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/event_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/event_attributes.h new file mode 100644 index 00000000000..c2faa437cf5 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/event_attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace event +{ + +/** + * Identifies the class / type of event. + *

        + * Event names are subject to the same rules as attribute names. Notably, event names are namespaced + * to avoid collisions and provide a clean separation of semantics for events in separate domains + * like browser, mobile, and kubernetes. + */ +static constexpr const char *kEventName = "event.name"; + +} // namespace event +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/exception_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/exception_attributes.h new file mode 100644 index 00000000000..fdc19ac6d0e --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/exception_attributes.h @@ -0,0 +1,59 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace exception +{ + +/** + * SHOULD be set to true if the exception event is recorded at a point where it is known that the + * exception is escaping the scope of the span.

        An exception is considered to have escaped (or + * left) the scope of a span, if that span is ended while the exception is still logically "in + * flight". This may be actually "in flight" in some languages (e.g. if the exception is passed to a + * Context manager's @code __exit__ @endcode method in Python) but will usually be caught at the + * point of recording the exception in most languages.

        It is usually not possible to determine + * at the point where an exception is thrown whether it will escape the scope of a span. However, it + * is trivial to know that an exception will escape, if one checks for an active exception just + * before ending the span, as done in the example + * for recording span exceptions.

        It follows that an exception may still escape the scope of + * the span even if the @code exception.escaped @endcode attribute was not set or set to false, + * since the event might have been recorded at a time where it was not + * clear whether the exception will escape. + */ +static constexpr const char *kExceptionEscaped = "exception.escaped"; + +/** + * The exception message. + */ +static constexpr const char *kExceptionMessage = "exception.message"; + +/** + * A stacktrace as a string in the natural representation for the language runtime. The + * representation is to be determined and documented by each language SIG. + */ +static constexpr const char *kExceptionStacktrace = "exception.stacktrace"; + +/** + * 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. + */ +static constexpr const char *kExceptionType = "exception.type"; + +} // namespace exception +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_attributes.h new file mode 100644 index 00000000000..ed9076ec39b --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_attributes.h @@ -0,0 +1,232 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace faas +{ + +/** + * A boolean that is true if the serverless function is executed for the first time (aka + * cold-start). + */ +static constexpr const char *kFaasColdstart = "faas.coldstart"; + +/** + * A string containing the schedule period as Cron + * Expression. + */ +static constexpr const char *kFaasCron = "faas.cron"; + +/** + * 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 *kFaasDocumentCollection = "faas.document.collection"; + +/** + * 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 *kFaasDocumentName = "faas.document.name"; + +/** + * Describes the type of the operation that was performed on the data. + */ +static constexpr const char *kFaasDocumentOperation = "faas.document.operation"; + +/** + * A string containing the time when the data was accessed in the ISO 8601 format expressed in UTC. + */ +static constexpr const char *kFaasDocumentTime = "faas.document.time"; + +/** + * The execution environment ID as a string, that will be potentially reused for other invocations + * to the same function/function version.

        • AWS Lambda: Use the (full) + * log stream name.
        • + *
        + */ +static constexpr const char *kFaasInstance = "faas.instance"; + +/** + * The invocation ID of the current function invocation. + */ +static constexpr const char *kFaasInvocationId = "faas.invocation_id"; + +/** + * The name of the invoked function. + *

        + * SHOULD be equal to the @code faas.name @endcode resource attribute of the invoked function. + */ +static constexpr const char *kFaasInvokedName = "faas.invoked_name"; + +/** + * The cloud provider of the invoked function. + *

        + * SHOULD be equal to the @code cloud.provider @endcode resource attribute of the invoked function. + */ +static constexpr const char *kFaasInvokedProvider = "faas.invoked_provider"; + +/** + * The cloud region of the invoked function. + *

        + * SHOULD be equal to the @code cloud.region @endcode resource attribute of the invoked function. + */ +static constexpr const char *kFaasInvokedRegion = "faas.invoked_region"; + +/** + * The amount of memory available to the serverless function converted to Bytes. + *

        + * 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 @endcode 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. + *

        + * 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 @endcode/@code + * code.function @endcode 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: The full name @code / @endcode, i.e., function app + * name followed by a forward slash followed by the function name (this form can also be seen in the + * resource JSON for the function). This means that a span attribute MUST be used, as an Azure + * function app can host multiple functions that would usually share a TracerProvider (see also the + * @code cloud.resource_id @endcode attribute).
        • + *
        + */ +static constexpr const char *kFaasName = "faas.name"; + +/** + * A string containing the function invocation time in the ISO 8601 format expressed in UTC. + */ +static constexpr const char *kFaasTime = "faas.time"; + +/** + * Type of the trigger which caused this function invocation. + */ +static constexpr const char *kFaasTrigger = "faas.trigger"; + +/** + * The immutable version of the function being executed. + *

        + * Depending on the cloud provider and platform, use: + *

        + *

        + */ +static constexpr const char *kFaasVersion = "faas.version"; + +namespace FaasDocumentOperationValues +{ +/** + * When a new object is created. + */ +static constexpr const char *kInsert = "insert"; + +/** + * When an object is modified. + */ +static constexpr const char *kEdit = "edit"; + +/** + * When an object is deleted. + */ +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 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 faas +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_metrics.h new file mode 100644 index 00000000000..73dc2989a62 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_metrics.h @@ -0,0 +1,287 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace faas +{ + +/** + * Number of invocation cold starts + *

        + * counter + */ +static constexpr const char *kMetricFaasColdstarts = "metric.faas.coldstarts"; +static constexpr const char *descrMetricFaasColdstarts = "Number of invocation cold starts"; +static constexpr const char *unitMetricFaasColdstarts = "{coldstart}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasColdstarts( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricFaasColdstarts, descrMetricFaasColdstarts, + unitMetricFaasColdstarts); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasColdstarts( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricFaasColdstarts, descrMetricFaasColdstarts, + unitMetricFaasColdstarts); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricFaasColdstarts( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricFaasColdstarts, descrMetricFaasColdstarts, + unitMetricFaasColdstarts); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricFaasColdstarts(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricFaasColdstarts, descrMetricFaasColdstarts, + unitMetricFaasColdstarts); +} + +/** + * Distribution of CPU usage per invocation + *

        + * histogram + */ +static constexpr const char *kMetricFaasCpuUsage = "metric.faas.cpu_usage"; +static constexpr const char *descrMetricFaasCpuUsage = "Distribution of CPU usage per invocation"; +static constexpr const char *unitMetricFaasCpuUsage = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasCpuUsage, descrMetricFaasCpuUsage, + unitMetricFaasCpuUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasCpuUsage, descrMetricFaasCpuUsage, + unitMetricFaasCpuUsage); +} + +/** + * Number of invocation errors + *

        + * counter + */ +static constexpr const char *kMetricFaasErrors = "metric.faas.errors"; +static constexpr const char *descrMetricFaasErrors = "Number of invocation errors"; +static constexpr const char *unitMetricFaasErrors = "{error}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasErrors( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricFaasErrors, descrMetricFaasErrors, unitMetricFaasErrors); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricFaasErrors, descrMetricFaasErrors, unitMetricFaasErrors); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricFaasErrors( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricFaasErrors, descrMetricFaasErrors, + unitMetricFaasErrors); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricFaasErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricFaasErrors, descrMetricFaasErrors, + unitMetricFaasErrors); +} + +/** + * Measures the duration of the function's initialization, such as a cold start + *

        + * histogram + */ +static constexpr const char *kMetricFaasInitDuration = "metric.faas.init_duration"; +static constexpr const char *descrMetricFaasInitDuration = + "Measures the duration of the function's initialization, such as a cold start"; +static constexpr const char *unitMetricFaasInitDuration = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasInitDuration( + metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasInitDuration, descrMetricFaasInitDuration, + unitMetricFaasInitDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasInitDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasInitDuration, descrMetricFaasInitDuration, + unitMetricFaasInitDuration); +} + +/** + * Number of successful invocations + *

        + * counter + */ +static constexpr const char *kMetricFaasInvocations = "metric.faas.invocations"; +static constexpr const char *descrMetricFaasInvocations = "Number of successful invocations"; +static constexpr const char *unitMetricFaasInvocations = "{invocation}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasInvocations( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricFaasInvocations, descrMetricFaasInvocations, + unitMetricFaasInvocations); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasInvocations( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricFaasInvocations, descrMetricFaasInvocations, + unitMetricFaasInvocations); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricFaasInvocations(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricFaasInvocations, descrMetricFaasInvocations, + unitMetricFaasInvocations); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricFaasInvocations(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricFaasInvocations, descrMetricFaasInvocations, + unitMetricFaasInvocations); +} + +/** + * Measures the duration of the function's logic execution + *

        + * histogram + */ +static constexpr const char *kMetricFaasInvokeDuration = "metric.faas.invoke_duration"; +static constexpr const char *descrMetricFaasInvokeDuration = + "Measures the duration of the function's logic execution"; +static constexpr const char *unitMetricFaasInvokeDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricFaasInvokeDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasInvokeDuration, descrMetricFaasInvokeDuration, + unitMetricFaasInvokeDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricFaasInvokeDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasInvokeDuration, descrMetricFaasInvokeDuration, + unitMetricFaasInvokeDuration); +} + +/** + * Distribution of max memory usage per invocation + *

        + * histogram + */ +static constexpr const char *kMetricFaasMemUsage = "metric.faas.mem_usage"; +static constexpr const char *descrMetricFaasMemUsage = + "Distribution of max memory usage per invocation"; +static constexpr const char *unitMetricFaasMemUsage = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasMemUsage( + metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasMemUsage, descrMetricFaasMemUsage, + unitMetricFaasMemUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasMemUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasMemUsage, descrMetricFaasMemUsage, + unitMetricFaasMemUsage); +} + +/** + * Distribution of net I/O usage per invocation + *

        + * histogram + */ +static constexpr const char *kMetricFaasNetIo = "metric.faas.net_io"; +static constexpr const char *descrMetricFaasNetIo = "Distribution of net I/O usage per invocation"; +static constexpr const char *unitMetricFaasNetIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasNetIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricFaasNetIo, descrMetricFaasNetIo, unitMetricFaasNetIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasNetIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricFaasNetIo, descrMetricFaasNetIo, unitMetricFaasNetIo); +} + +/** + * Number of invocation timeouts + *

        + * counter + */ +static constexpr const char *kMetricFaasTimeouts = "metric.faas.timeouts"; +static constexpr const char *descrMetricFaasTimeouts = "Number of invocation timeouts"; +static constexpr const char *unitMetricFaasTimeouts = "{timeout}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricFaasTimeouts( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricFaasTimeouts, descrMetricFaasTimeouts, + unitMetricFaasTimeouts); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricFaasTimeouts( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricFaasTimeouts, descrMetricFaasTimeouts, + unitMetricFaasTimeouts); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricFaasTimeouts( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricFaasTimeouts, descrMetricFaasTimeouts, + unitMetricFaasTimeouts); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricFaasTimeouts( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricFaasTimeouts, descrMetricFaasTimeouts, + unitMetricFaasTimeouts); +} + +} // namespace faas +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h new file mode 100644 index 00000000000..3cd8b8eb2c1 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace feature_flag +{ + +/** + * The unique identifier of the feature flag. + */ +static constexpr const char *kFeatureFlagKey = "feature_flag.key"; + +/** + * The name of the service provider that performs the flag evaluation. + */ +static constexpr const char *kFeatureFlagProviderName = "feature_flag.provider_name"; + +/** + * SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the + * value can be used.

        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 @endcode maybe be used for the value @code #c05543 @endcode. + *

        + * 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 *kFeatureFlagVariant = "feature_flag.variant"; + +} // namespace feature_flag +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/file_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/file_attributes.h new file mode 100644 index 00000000000..2ac4fc4b55d --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/file_attributes.h @@ -0,0 +1,144 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace file +{ + +/** + * Time when the file was last accessed, in ISO 8601 format. + *

        + * This attribute might not be supported by some file systems — NFS, FAT32, in embedded OS, etc. + */ +static constexpr const char *kFileAccessed = "file.accessed"; + +/** + * Array of file attributes. + *

        + * Attributes names depend on the OS or file system. Here’s a non-exhaustive list of values expected + * for this attribute: @code archive @endcode, @code compressed @endcode, @code directory @endcode, + * @code encrypted @endcode, @code execute @endcode, @code hidden @endcode, @code immutable + * @endcode, @code journaled @endcode, @code read @endcode, @code readonly @endcode, @code symbolic + * link @endcode, @code system @endcode, @code temporary @endcode, @code write @endcode. + */ +static constexpr const char *kFileAttributes = "file.attributes"; + +/** + * Time when the file attributes or metadata was last changed, in ISO 8601 format. + *

        + * @code file.changed @endcode captures the time when any of the file's properties or attributes + * (including the content) are changed, while @code file.modified @endcode captures the timestamp + * when the file content is modified. + */ +static constexpr const char *kFileChanged = "file.changed"; + +/** + * Time when the file was created, in ISO 8601 format. + *

        + * This attribute might not be supported by some file systems — NFS, FAT32, in embedded OS, etc. + */ +static constexpr const char *kFileCreated = "file.created"; + +/** + * Directory where the file is located. It should include the drive letter, when appropriate. + */ +static constexpr const char *kFileDirectory = "file.directory"; + +/** + * File extension, excluding the leading dot. + *

        + * When the file name has multiple extensions (example.tar.gz), only the last one should be captured + * ("gz", not "tar.gz"). + */ +static constexpr const char *kFileExtension = "file.extension"; + +/** + * Name of the fork. A fork is additional data associated with a filesystem object. + *

        + * On Linux, a resource fork is used to store additional data with a filesystem object. A file + * always has at least one fork for the data portion, and additional forks may exist. On NTFS, this + * is analogous to an Alternate Data Stream (ADS), and the default data stream for a file is just + * called $DATA. Zone.Identifier is commonly used by Windows to track contents downloaded from the + * Internet. An ADS is typically of the form: C:\path\to\filename.extension:some_fork_name, and + * some_fork_name is the value that should populate @code fork_name @endcode. @code + * filename.extension @endcode should populate @code file.name @endcode, and @code extension + * @endcode should populate @code file.extension @endcode. The full path, @code file.path @endcode, + * will include the fork name. + */ +static constexpr const char *kFileForkName = "file.fork_name"; + +/** + * Primary Group ID (GID) of the file. + */ +static constexpr const char *kFileGroupId = "file.group.id"; + +/** + * Primary group name of the file. + */ +static constexpr const char *kFileGroupName = "file.group.name"; + +/** + * Inode representing the file in the filesystem. + */ +static constexpr const char *kFileInode = "file.inode"; + +/** + * Mode of the file in octal representation. + */ +static constexpr const char *kFileMode = "file.mode"; + +/** + * Time when the file content was last modified, in ISO 8601 format. + */ +static constexpr const char *kFileModified = "file.modified"; + +/** + * Name of the file including the extension, without the directory. + */ +static constexpr const char *kFileName = "file.name"; + +/** + * The user ID (UID) or security identifier (SID) of the file owner. + */ +static constexpr const char *kFileOwnerId = "file.owner.id"; + +/** + * Username of the file owner. + */ +static constexpr const char *kFileOwnerName = "file.owner.name"; + +/** + * Full path to the file, including the file name. It should include the drive letter, when + * appropriate. + */ +static constexpr const char *kFilePath = "file.path"; + +/** + * File size in bytes. + */ +static constexpr const char *kFileSize = "file.size"; + +/** + * Path to the target of a symbolic link. + *

        + * This attribute is only applicable to symbolic links. + */ +static constexpr const char *kFileSymbolicLinkTargetPath = "file.symbolic_link.target_path"; + +} // namespace file +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gcp_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gcp_attributes.h new file mode 100644 index 00000000000..53518251bbf --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gcp_attributes.h @@ -0,0 +1,64 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace gcp +{ + +/** + * Identifies the Google Cloud service for which the official client library is intended. + *

        + * Intended to be a stable identifier for Google Cloud client libraries that is uniform across + * implementation languages. The value should be derived from the canonical service domain for the + * service; for example, 'foo.googleapis.com' should result in a value of 'foo'. + */ +static constexpr const char *kGcpClientService = "gcp.client.service"; + +/** + * The name of the Cloud Run execution being run for the + * Job, as set by the @code + * CLOUD_RUN_EXECUTION @endcode environment variable. + */ +static constexpr const char *kGcpCloudRunJobExecution = "gcp.cloud_run.job.execution"; + +/** + * The index for a task within an execution as provided by the @code + * CLOUD_RUN_TASK_INDEX @endcode environment variable. + */ +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 @endcode, the + * visible name of the instance in the Cloud Console UI, and the prefix for the default hostname of + * the instance as defined by the default + * internal DNS name. + */ +static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; + +} // namespace gcp +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h new file mode 100644 index 00000000000..ce4a939d07e --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h @@ -0,0 +1,263 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace gen_ai +{ + +/** + * Deprecated, use Event API to report completions contents. + *

        + * @deprecated + * Removed, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiCompletion = "gen_ai.completion"; + +/** + * The response format that is requested. + */ +static constexpr const char *kGenAiOpenaiRequestResponseFormat = + "gen_ai.openai.request.response_format"; + +/** + * Requests with same seed value more likely to return same result. + */ +static constexpr const char *kGenAiOpenaiRequestSeed = "gen_ai.openai.request.seed"; + +/** + * The service tier requested. May be a specific tier, detault, or auto. + */ +static constexpr const char *kGenAiOpenaiRequestServiceTier = "gen_ai.openai.request.service_tier"; + +/** + * The service tier used for the response. + */ +static constexpr const char *kGenAiOpenaiResponseServiceTier = + "gen_ai.openai.response.service_tier"; + +/** + * The name of the operation being performed. + *

        + * If one of the predefined values applies, but specific system uses a different name it's + * RECOMMENDED to document it in the semantic conventions for specific GenAI system and use + * system-specific name in the instrumentation. If a different name is not documented, + * instrumentation libraries SHOULD use applicable predefined value. + */ +static constexpr const char *kGenAiOperationName = "gen_ai.operation.name"; + +/** + * Deprecated, use Event API to report prompt contents. + *

        + * @deprecated + * Removed, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiPrompt = "gen_ai.prompt"; + +/** + * The frequency penalty setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestFrequencyPenalty = "gen_ai.request.frequency_penalty"; + +/** + * The maximum number of tokens the model generates for a request. + */ +static constexpr const char *kGenAiRequestMaxTokens = "gen_ai.request.max_tokens"; + +/** + * The name of the GenAI model a request is being made to. + */ +static constexpr const char *kGenAiRequestModel = "gen_ai.request.model"; + +/** + * The presence penalty setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestPresencePenalty = "gen_ai.request.presence_penalty"; + +/** + * List of sequences that the model will use to stop generating further tokens. + */ +static constexpr const char *kGenAiRequestStopSequences = "gen_ai.request.stop_sequences"; + +/** + * The temperature setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestTemperature = "gen_ai.request.temperature"; + +/** + * The top_k sampling setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestTopK = "gen_ai.request.top_k"; + +/** + * The top_p sampling setting for the GenAI request. + */ +static constexpr const char *kGenAiRequestTopP = "gen_ai.request.top_p"; + +/** + * Array of reasons the model stopped generating tokens, corresponding to each generation received. + */ +static constexpr const char *kGenAiResponseFinishReasons = "gen_ai.response.finish_reasons"; + +/** + * The unique identifier for the completion. + */ +static constexpr const char *kGenAiResponseId = "gen_ai.response.id"; + +/** + * The name of the model that generated the response. + */ +static constexpr const char *kGenAiResponseModel = "gen_ai.response.model"; + +/** + * The Generative AI product as identified by the client or server instrumentation. + *

        + * The @code gen_ai.system @endcode describes a family of GenAI models with specific model + * identified by @code gen_ai.request.model @endcode and @code gen_ai.response.model @endcode + * attributes.

        The actual GenAI product may differ from the one identified by the client. For + * example, when using OpenAI client libraries to communicate with Mistral, the @code gen_ai.system + * @endcode is set to @code openai @endcode based on the instrumentation's best knowledge.

        For + * custom model, a custom friendly name SHOULD be used. If none of these options apply, the @code + * gen_ai.system @endcode SHOULD be set to @code _OTHER @endcode. + */ +static constexpr const char *kGenAiSystem = "gen_ai.system"; + +/** + * The type of token being counted. + */ +static constexpr const char *kGenAiTokenType = "gen_ai.token.type"; + +/** + * Deprecated, use @code gen_ai.usage.output_tokens @endcode instead. + *

        + * @deprecated + * Replaced by @code gen_ai.usage.output_tokens @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; + +/** + * The number of tokens used in the GenAI input (prompt). + */ +static constexpr const char *kGenAiUsageInputTokens = "gen_ai.usage.input_tokens"; + +/** + * The number of tokens used in the GenAI response (completion). + */ +static constexpr const char *kGenAiUsageOutputTokens = "gen_ai.usage.output_tokens"; + +/** + * Deprecated, use @code gen_ai.usage.input_tokens @endcode instead. + *

        + * @deprecated + * Replaced by @code gen_ai.usage.input_tokens @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; + +namespace GenAiOpenaiRequestResponseFormatValues +{ +/** + * Text response format + */ +static constexpr const char *kText = "text"; + +/** + * JSON object response format + */ +static constexpr const char *kJsonObject = "json_object"; + +/** + * JSON schema response format + */ +static constexpr const char *kJsonSchema = "json_schema"; + +} // namespace GenAiOpenaiRequestResponseFormatValues + +namespace GenAiOpenaiRequestServiceTierValues +{ +/** + * The system will utilize scale tier credits until they are exhausted. + */ +static constexpr const char *kAuto = "auto"; + +/** + * The system will utilize the default scale tier. + */ +static constexpr const char *kDefault = "default"; + +} // namespace GenAiOpenaiRequestServiceTierValues + +namespace GenAiOperationNameValues +{ +/** + * Chat completion operation such as OpenAI Chat API + */ +static constexpr const char *kChat = "chat"; + +/** + * Text completions operation such as OpenAI Completions API + * (Legacy) + */ +static constexpr const char *kTextCompletion = "text_completion"; + +} // namespace GenAiOperationNameValues + +namespace GenAiSystemValues +{ +/** + * OpenAI + */ +static constexpr const char *kOpenai = "openai"; + +/** + * Vertex AI + */ +static constexpr const char *kVertexAi = "vertex_ai"; + +/** + * Anthropic + */ +static constexpr const char *kAnthropic = "anthropic"; + +/** + * Cohere + */ +static constexpr const char *kCohere = "cohere"; + +} // namespace GenAiSystemValues + +namespace GenAiTokenTypeValues +{ +/** + * Input tokens (prompt, input, etc.) + */ +static constexpr const char *kInput = "input"; + +/** + * Output tokens (completion, response, etc.) + */ +static constexpr const char *kCompletion = "output"; + +} // namespace GenAiTokenTypeValues + +} // namespace gen_ai +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h new file mode 100644 index 00000000000..6a9064c3e72 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h @@ -0,0 +1,158 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace gen_ai +{ + +/** + * GenAI operation duration + *

        + * histogram + */ +static constexpr const char *kMetricGenAiClientOperationDuration = + "metric.gen_ai.client.operation.duration"; +static constexpr const char *descrMetricGenAiClientOperationDuration = "GenAI operation duration"; +static constexpr const char *unitMetricGenAiClientOperationDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiClientOperationDuration, + descrMetricGenAiClientOperationDuration, + unitMetricGenAiClientOperationDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiClientOperationDuration, + descrMetricGenAiClientOperationDuration, + unitMetricGenAiClientOperationDuration); +} + +/** + * Measures number of input and output tokens used + *

        + * histogram + */ +static constexpr const char *kMetricGenAiClientTokenUsage = "metric.gen_ai.client.token.usage"; +static constexpr const char *descrMetricGenAiClientTokenUsage = + "Measures number of input and output tokens used"; +static constexpr const char *unitMetricGenAiClientTokenUsage = "{token}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiClientTokenUsage(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiClientTokenUsage, + descrMetricGenAiClientTokenUsage, + unitMetricGenAiClientTokenUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiClientTokenUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiClientTokenUsage, + descrMetricGenAiClientTokenUsage, + unitMetricGenAiClientTokenUsage); +} + +/** + * Generative AI server request duration such as time-to-last byte or last output token + *

        + * histogram + */ +static constexpr const char *kMetricGenAiServerRequestDuration = + "metric.gen_ai.server.request.duration"; +static constexpr const char *descrMetricGenAiServerRequestDuration = + "Generative AI server request duration such as time-to-last byte or last output token"; +static constexpr const char *unitMetricGenAiServerRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiServerRequestDuration, + descrMetricGenAiServerRequestDuration, + unitMetricGenAiServerRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiServerRequestDuration, + descrMetricGenAiServerRequestDuration, + unitMetricGenAiServerRequestDuration); +} + +/** + * Time per output token generated after the first token for successful responses + *

        + * histogram + */ +static constexpr const char *kMetricGenAiServerTimePerOutputToken = + "metric.gen_ai.server.time_per_output_token"; +static constexpr const char *descrMetricGenAiServerTimePerOutputToken = + "Time per output token generated after the first token for successful responses"; +static constexpr const char *unitMetricGenAiServerTimePerOutputToken = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiServerTimePerOutputToken(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiServerTimePerOutputToken, + descrMetricGenAiServerTimePerOutputToken, + unitMetricGenAiServerTimePerOutputToken); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiServerTimePerOutputToken(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiServerTimePerOutputToken, + descrMetricGenAiServerTimePerOutputToken, + unitMetricGenAiServerTimePerOutputToken); +} + +/** + * Time to generate first token for successful responses + *

        + * histogram + */ +static constexpr const char *kMetricGenAiServerTimeToFirstToken = + "metric.gen_ai.server.time_to_first_token"; +static constexpr const char *descrMetricGenAiServerTimeToFirstToken = + "Time to generate first token for successful responses"; +static constexpr const char *unitMetricGenAiServerTimeToFirstToken = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricGenAiServerTimeToFirstToken(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricGenAiServerTimeToFirstToken, + descrMetricGenAiServerTimeToFirstToken, + unitMetricGenAiServerTimeToFirstToken); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricGenAiServerTimeToFirstToken(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricGenAiServerTimeToFirstToken, + descrMetricGenAiServerTimeToFirstToken, + unitMetricGenAiServerTimeToFirstToken); +} + +} // namespace gen_ai +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/graphql_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/graphql_attributes.h new file mode 100644 index 00000000000..fe899d1c69b --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/graphql_attributes.h @@ -0,0 +1,60 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace graphql +{ + +/** + * The GraphQL document being executed. + *

        + * The value may be sanitized to exclude sensitive information. + */ +static constexpr const char *kGraphqlDocument = "graphql.document"; + +/** + * The name of the operation being executed. + */ +static constexpr const char *kGraphqlOperationName = "graphql.operation.name"; + +/** + * The type of the operation being executed. + */ +static constexpr const char *kGraphqlOperationType = "graphql.operation.type"; + +namespace GraphqlOperationTypeValues +{ +/** + * GraphQL query + */ +static constexpr const char *kQuery = "query"; + +/** + * GraphQL mutation + */ +static constexpr const char *kMutation = "mutation"; + +/** + * GraphQL subscription + */ +static constexpr const char *kSubscription = "subscription"; + +} // namespace GraphqlOperationTypeValues + +} // namespace graphql +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/heroku_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/heroku_attributes.h new file mode 100644 index 00000000000..a16bd331617 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/heroku_attributes.h @@ -0,0 +1,39 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace heroku +{ + +/** + * Unique identifier for the application + */ +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 + */ +static constexpr const char *kHerokuReleaseCreationTimestamp = "heroku.release.creation_timestamp"; + +} // namespace heroku +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/host_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/host_attributes.h new file mode 100644 index 00000000000..e608bd5d460 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/host_attributes.h @@ -0,0 +1,159 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace host +{ + +/** + * The CPU architecture the host system is running on. + */ +static constexpr const char *kHostArch = "host.arch"; + +/** + * The amount of level 2 memory cache available to the processor (in Bytes). + */ +static constexpr const char *kHostCpuCacheL2Size = "host.cpu.cache.l2.size"; + +/** + * Family or generation of the CPU. + */ +static constexpr const char *kHostCpuFamily = "host.cpu.family"; + +/** + * Model identifier. It provides more granular information about the CPU, distinguishing it from + * other CPUs within the same family. + */ +static constexpr const char *kHostCpuModelId = "host.cpu.model.id"; + +/** + * Model designation of the processor. + */ +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. + *

        + * 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"; + +/** + * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For + * non-containerized systems, this should be the @code machine-id @endcode. See the table below for + * the sources to use to determine the @code machine-id @endcode based on operating system. + */ +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. + *

        + * 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"; + +/** + * Available MAC addresses of the host, excluding loopback interfaces. + *

        + * MAC Addresses MUST be represented in IEEE RA + * hexadecimal form: as hyphen-separated octets in uppercase hexadecimal form from most to least + * significant. + */ +static constexpr const char *kHostMac = "host.mac"; + +/** + * 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. + */ +static constexpr const char *kHostName = "host.name"; + +/** + * Type of host. For Cloud, this must be the machine type. + */ +static constexpr const char *kHostType = "host.type"; + +namespace HostArchValues +{ +/** + * AMD64 + */ +static constexpr const char *kAmd64 = "amd64"; + +/** + * ARM32 + */ +static constexpr const char *kArm32 = "arm32"; + +/** + * ARM64 + */ +static constexpr const char *kArm64 = "arm64"; + +/** + * Itanium + */ +static constexpr const char *kIa64 = "ia64"; + +/** + * 32-bit PowerPC + */ +static constexpr const char *kPpc32 = "ppc32"; + +/** + * 64-bit PowerPC + */ +static constexpr const char *kPpc64 = "ppc64"; + +/** + * IBM z/Architecture + */ +static constexpr const char *kS390x = "s390x"; + +/** + * 32-bit x86 + */ +static constexpr const char *kX86 = "x86"; + +} // namespace HostArchValues + +} // namespace host +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/http_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/http_attributes.h new file mode 100644 index 00000000000..8f909f5297e --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/http_attributes.h @@ -0,0 +1,365 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace http +{ + +/** + * Deprecated, use @code client.address @endcode instead. + *

        + * @deprecated + * Replaced by @code client.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpClientIp = "http.client_ip"; + +/** + * State of the HTTP connection in the HTTP connection pool. + */ +static constexpr const char *kHttpConnectionState = "http.connection.state"; + +/** + * Deprecated, use @code network.protocol.name @endcode instead. + *

        + * @deprecated + * Replaced by @code network.protocol.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpFlavor = "http.flavor"; + +/** + * Deprecated, use one of @code server.address @endcode, @code client.address @endcode or @code + * http.request.header.host @endcode instead, depending on the usage.

        + * @deprecated + * Replaced by one of @code server.address @endcode, @code client.address @endcode or @code + * http.request.header.host @endcode, depending on the usage. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpHost = "http.host"; + +/** + * Deprecated, use @code http.request.method @endcode instead. + *

        + * @deprecated + * Replaced by @code http.request.method @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpMethod = "http.method"; + +/** + * 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 headers, @code @endcode being the normalized HTTP Header name (lowercase), the + * value being the header values.

        Instrumentations SHOULD require an explicit configuration of + * which headers are to be captured. Including all request headers can be a security risk - explicit + * configuration helps avoid leaking sensitive information. The @code User-Agent @endcode header is + * already captured in the @code user_agent.original @endcode attribute. Users MAY explicitly + * configure instrumentations to capture them even though it is not recommended. The attribute value + * MUST consist of either multiple header values as an array of strings or a single-item array + * containing a possibly comma-concatenated string, depending on the way the HTTP library provides + * access to headers. + */ +static constexpr const char *kHttpRequestHeader = "http.request.header"; + +/** + * HTTP request method. + *

        + * 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 + * @endcode attribute to @code _OTHER @endcode.

        If the HTTP instrumentation could end up + * converting valid HTTP request methods to @code _OTHER @endcode, 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 @endcode 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 @endcode to the + * original value. + */ +static constexpr const char *kHttpRequestMethod = "http.request.method"; + +/** + * Original HTTP method sent by the client in the request line. + */ +static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original"; + +/** + * The ordinal number of request resending attempt (for any reason, including redirects). + *

        + * 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 *kHttpRequestResendCount = "http.request.resend_count"; + +/** + * The total size of the request in bytes. This should be the total number of bytes sent over the + * wire, including the request line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and request + * body if any. + */ +static constexpr const char *kHttpRequestSize = "http.request.size"; + +/** + * Deprecated, use @code http.request.header. @endcode instead. + *

        + * @deprecated + * Replaced by @code http.request.header. @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; + +/** + * Deprecated, use @code http.request.body.size @endcode instead. + *

        + * @deprecated + * Replaced by @code http.request.body.size @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpRequestContentLengthUncompressed = + "http.request_content_length_uncompressed"; + +/** + * 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 *kHttpResponseBodySize = "http.response.body.size"; + +/** + * HTTP response headers, @code @endcode being the normalized HTTP Header name (lowercase), + * the value being the header values.

        Instrumentations SHOULD require an explicit configuration + * of which headers are to be captured. Including all response headers can be a security risk - + * explicit configuration helps avoid leaking sensitive information. Users MAY explicitly configure + * instrumentations to capture them even though it is not recommended. The attribute value MUST + * consist of either multiple header values as an array of strings or a single-item array containing + * a possibly comma-concatenated string, depending on the way the HTTP library provides access to + * headers. + */ +static constexpr const char *kHttpResponseHeader = "http.response.header"; + +/** + * The total size of the response in bytes. This should be the total number of bytes sent over the + * wire, including the status line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and response + * body and trailers if any. + */ +static constexpr const char *kHttpResponseSize = "http.response.size"; + +/** + * HTTP response status code. + */ +static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; + +/** + * Deprecated, use @code http.response.header. @endcode instead. + *

        + * @deprecated + * Replaced by @code http.response.header. @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; + +/** + * Deprecated, use @code http.response.body.size @endcode instead. + *

        + * @deprecated + * Replace by @code http.response.body.size @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpResponseContentLengthUncompressed = + "http.response_content_length_uncompressed"; + +/** + * The matched route, that is, the path template in the format used by the respective server + * framework.

        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 *kHttpRoute = "http.route"; + +/** + * Deprecated, use @code url.scheme @endcode instead. + *

        + * @deprecated + * Replaced by @code url.scheme @endcode instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpScheme = "http.scheme"; + +/** + * Deprecated, use @code server.address @endcode instead. + *

        + * @deprecated + * Replaced by @code server.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpServerName = "http.server_name"; + +/** + * Deprecated, use @code http.response.status_code @endcode instead. + *

        + * @deprecated + * Replaced by @code http.response.status_code @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpStatusCode = "http.status_code"; + +/** + * Deprecated, use @code url.path @endcode and @code url.query @endcode instead. + *

        + * @deprecated + * Split to @code url.path @endcode and `url.query. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpTarget = "http.target"; + +/** + * Deprecated, use @code url.full @endcode instead. + *

        + * @deprecated + * Replaced by @code url.full @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpUrl = "http.url"; + +/** + * Deprecated, use @code user_agent.original @endcode instead. + *

        + * @deprecated + * Replaced by @code user_agent.original @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpUserAgent = "http.user_agent"; + +namespace HttpConnectionStateValues +{ +/** + * active state. + */ +static constexpr const char *kActive = "active"; + +/** + * idle state. + */ +static constexpr const char *kIdle = "idle"; + +} // namespace HttpConnectionStateValues + +namespace HttpFlavorValues +{ +/** + * HTTP/1.0 + */ +static constexpr const char *kHttp10 = "1.0"; + +/** + * HTTP/1.1 + */ +static constexpr const char *kHttp11 = "1.1"; + +/** + * HTTP/2 + */ +static constexpr const char *kHttp20 = "2.0"; + +/** + * HTTP/3 + */ +static constexpr const char *kHttp30 = "3.0"; + +/** + * SPDY protocol. + */ +static constexpr const char *kSpdy = "SPDY"; + +/** + * QUIC protocol. + */ +static constexpr const char *kQuic = "QUIC"; + +} // namespace HttpFlavorValues + +namespace HttpRequestMethodValues +{ +/** + * CONNECT method. + */ +static constexpr const char *kConnect = "CONNECT"; + +/** + * DELETE method. + */ +static constexpr const char *kDelete = "DELETE"; + +/** + * GET method. + */ +static constexpr const char *kGet = "GET"; + +/** + * HEAD method. + */ +static constexpr const char *kHead = "HEAD"; + +/** + * OPTIONS method. + */ +static constexpr const char *kOptions = "OPTIONS"; + +/** + * PATCH method. + */ +static constexpr const char *kPatch = "PATCH"; + +/** + * POST method. + */ +static constexpr const char *kPost = "POST"; + +/** + * PUT method. + */ +static constexpr const char *kPut = "PUT"; + +/** + * TRACE method. + */ +static constexpr const char *kTrace = "TRACE"; + +/** + * Any HTTP method that the instrumentation has no prior knowledge of. + */ +static constexpr const char *kOther = "_OTHER"; + +} // namespace HttpRequestMethodValues + +} // namespace http +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/http_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/http_metrics.h new file mode 100644 index 00000000000..9142b6c44f5 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/http_metrics.h @@ -0,0 +1,353 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace http +{ + +/** + * Number of active HTTP requests. + *

        + * updowncounter + */ +static constexpr const char *kMetricHttpClientActiveRequests = "metric.http.client.active_requests"; +static constexpr const char *descrMetricHttpClientActiveRequests = + "Number of active HTTP requests."; +static constexpr const char *unitMetricHttpClientActiveRequests = "{request}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientActiveRequests(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHttpClientActiveRequests, + descrMetricHttpClientActiveRequests, + unitMetricHttpClientActiveRequests); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientActiveRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHttpClientActiveRequests, + descrMetricHttpClientActiveRequests, + unitMetricHttpClientActiveRequests); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHttpClientActiveRequests(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHttpClientActiveRequests, + descrMetricHttpClientActiveRequests, + unitMetricHttpClientActiveRequests); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHttpClientActiveRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHttpClientActiveRequests, + descrMetricHttpClientActiveRequests, + unitMetricHttpClientActiveRequests); +} + +/** + * The duration of the successfully established outbound HTTP connections. + *

        + * histogram + */ +static constexpr const char *kMetricHttpClientConnectionDuration = + "metric.http.client.connection.duration"; +static constexpr const char *descrMetricHttpClientConnectionDuration = + "The duration of the successfully established outbound HTTP connections."; +static constexpr const char *unitMetricHttpClientConnectionDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientConnectionDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientConnectionDuration, + descrMetricHttpClientConnectionDuration, + unitMetricHttpClientConnectionDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientConnectionDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientConnectionDuration, + descrMetricHttpClientConnectionDuration, + unitMetricHttpClientConnectionDuration); +} + +/** + * Number of outbound HTTP connections that are currently active or idle on the client. + *

        + * updowncounter + */ +static constexpr const char *kMetricHttpClientOpenConnections = + "metric.http.client.open_connections"; +static constexpr const char *descrMetricHttpClientOpenConnections = + "Number of outbound HTTP connections that are currently active or idle on the client."; +static constexpr const char *unitMetricHttpClientOpenConnections = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientOpenConnections(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHttpClientOpenConnections, + descrMetricHttpClientOpenConnections, + unitMetricHttpClientOpenConnections); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientOpenConnections(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHttpClientOpenConnections, + descrMetricHttpClientOpenConnections, + unitMetricHttpClientOpenConnections); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHttpClientOpenConnections(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHttpClientOpenConnections, + descrMetricHttpClientOpenConnections, + unitMetricHttpClientOpenConnections); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHttpClientOpenConnections(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHttpClientOpenConnections, + descrMetricHttpClientOpenConnections, + unitMetricHttpClientOpenConnections); +} + +/** + * Size of HTTP client request bodies. + *

        + * 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.

        histogram + */ +static constexpr const char *kMetricHttpClientRequestBodySize = + "metric.http.client.request.body.size"; +static constexpr const char *descrMetricHttpClientRequestBodySize = + "Size of HTTP client request bodies."; +static constexpr const char *unitMetricHttpClientRequestBodySize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientRequestBodySize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientRequestBodySize, + descrMetricHttpClientRequestBodySize, + unitMetricHttpClientRequestBodySize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientRequestBodySize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientRequestBodySize, + descrMetricHttpClientRequestBodySize, + unitMetricHttpClientRequestBodySize); +} + +/** + * Duration of HTTP client requests. + *

        + * histogram + */ +static constexpr const char *kMetricHttpClientRequestDuration = + "metric.http.client.request.duration"; +static constexpr const char *descrMetricHttpClientRequestDuration = + "Duration of HTTP client requests."; +static constexpr const char *unitMetricHttpClientRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientRequestDuration, + descrMetricHttpClientRequestDuration, + unitMetricHttpClientRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientRequestDuration, + descrMetricHttpClientRequestDuration, + unitMetricHttpClientRequestDuration); +} + +/** + * Size of HTTP client response bodies. + *

        + * 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.

        histogram + */ +static constexpr const char *kMetricHttpClientResponseBodySize = + "metric.http.client.response.body.size"; +static constexpr const char *descrMetricHttpClientResponseBodySize = + "Size of HTTP client response bodies."; +static constexpr const char *unitMetricHttpClientResponseBodySize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpClientResponseBodySize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpClientResponseBodySize, + descrMetricHttpClientResponseBodySize, + unitMetricHttpClientResponseBodySize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpClientResponseBodySize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpClientResponseBodySize, + descrMetricHttpClientResponseBodySize, + unitMetricHttpClientResponseBodySize); +} + +/** + * Number of active HTTP server requests. + *

        + * updowncounter + */ +static constexpr const char *kMetricHttpServerActiveRequests = "metric.http.server.active_requests"; +static constexpr const char *descrMetricHttpServerActiveRequests = + "Number of active HTTP server requests."; +static constexpr const char *unitMetricHttpServerActiveRequests = "{request}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerActiveRequests(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHttpServerActiveRequests, + descrMetricHttpServerActiveRequests, + unitMetricHttpServerActiveRequests); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerActiveRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHttpServerActiveRequests, + descrMetricHttpServerActiveRequests, + unitMetricHttpServerActiveRequests); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHttpServerActiveRequests(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHttpServerActiveRequests, + descrMetricHttpServerActiveRequests, + unitMetricHttpServerActiveRequests); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHttpServerActiveRequests(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHttpServerActiveRequests, + descrMetricHttpServerActiveRequests, + unitMetricHttpServerActiveRequests); +} + +/** + * Size of HTTP server request bodies. + *

        + * 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.

        histogram + */ +static constexpr const char *kMetricHttpServerRequestBodySize = + "metric.http.server.request.body.size"; +static constexpr const char *descrMetricHttpServerRequestBodySize = + "Size of HTTP server request bodies."; +static constexpr const char *unitMetricHttpServerRequestBodySize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerRequestBodySize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpServerRequestBodySize, + descrMetricHttpServerRequestBodySize, + unitMetricHttpServerRequestBodySize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerRequestBodySize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpServerRequestBodySize, + descrMetricHttpServerRequestBodySize, + unitMetricHttpServerRequestBodySize); +} + +/** + * Duration of HTTP server requests. + *

        + * histogram + */ +static constexpr const char *kMetricHttpServerRequestDuration = + "metric.http.server.request.duration"; +static constexpr const char *descrMetricHttpServerRequestDuration = + "Duration of HTTP server requests."; +static constexpr const char *unitMetricHttpServerRequestDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpServerRequestDuration, + descrMetricHttpServerRequestDuration, + unitMetricHttpServerRequestDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerRequestDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpServerRequestDuration, + descrMetricHttpServerRequestDuration, + unitMetricHttpServerRequestDuration); +} + +/** + * Size of HTTP server response bodies. + *

        + * 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.

        histogram + */ +static constexpr const char *kMetricHttpServerResponseBodySize = + "metric.http.server.response.body.size"; +static constexpr const char *descrMetricHttpServerResponseBodySize = + "Size of HTTP server response bodies."; +static constexpr const char *unitMetricHttpServerResponseBodySize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHttpServerResponseBodySize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricHttpServerResponseBodySize, + descrMetricHttpServerResponseBodySize, + unitMetricHttpServerResponseBodySize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHttpServerResponseBodySize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricHttpServerResponseBodySize, + descrMetricHttpServerResponseBodySize, + unitMetricHttpServerResponseBodySize); +} + +} // namespace http +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_attributes.h new file mode 100644 index 00000000000..d87fe1f3db1 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_attributes.h @@ -0,0 +1,148 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace hw +{ + +/** + * An identifier for the hardware component, unique within the monitored host + */ +static constexpr const char *kHwId = "hw.id"; + +/** + * An easily-recognizable name for the hardware component + */ +static constexpr const char *kHwName = "hw.name"; + +/** + * Unique identifier of the parent component (typically the @code hw.id @endcode attribute of the + * enclosure, or disk controller) + */ +static constexpr const char *kHwParent = "hw.parent"; + +/** + * The current state of the component + */ +static constexpr const char *kHwState = "hw.state"; + +/** + * Type of the component + *

        + * Describes the category of the hardware component for which @code hw.state @endcode is being + * reported. For example, @code hw.type=temperature @endcode along with @code hw.state=degraded + * @endcode would indicate that the temperature of the hardware component has been reported as @code + * degraded @endcode. + */ +static constexpr const char *kHwType = "hw.type"; + +namespace HwStateValues +{ +/** + * Ok + */ +static constexpr const char *kOk = "ok"; + +/** + * Degraded + */ +static constexpr const char *kDegraded = "degraded"; + +/** + * Failed + */ +static constexpr const char *kFailed = "failed"; + +} // namespace HwStateValues + +namespace HwTypeValues +{ +/** + * Battery + */ +static constexpr const char *kBattery = "battery"; + +/** + * CPU + */ +static constexpr const char *kCpu = "cpu"; + +/** + * Disk controller + */ +static constexpr const char *kDiskController = "disk_controller"; + +/** + * Enclosure + */ +static constexpr const char *kEnclosure = "enclosure"; + +/** + * Fan + */ +static constexpr const char *kFan = "fan"; + +/** + * GPU + */ +static constexpr const char *kGpu = "gpu"; + +/** + * Logical disk + */ +static constexpr const char *kLogicalDisk = "logical_disk"; + +/** + * Memory + */ +static constexpr const char *kMemory = "memory"; + +/** + * Network + */ +static constexpr const char *kNetwork = "network"; + +/** + * Physical disk + */ +static constexpr const char *kPhysicalDisk = "physical_disk"; + +/** + * Power supply + */ +static constexpr const char *kPowerSupply = "power_supply"; + +/** + * Tape drive + */ +static constexpr const char *kTapeDrive = "tape_drive"; + +/** + * Temperature + */ +static constexpr const char *kTemperature = "temperature"; + +/** + * Voltage + */ +static constexpr const char *kVoltage = "voltage"; + +} // namespace HwTypeValues + +} // namespace hw +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_metrics.h new file mode 100644 index 00000000000..3a87fd25064 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_metrics.h @@ -0,0 +1,174 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace hw +{ + +/** + * Energy consumed by the component + *

        + * counter + */ +static constexpr const char *kMetricHwEnergy = "metric.hw.energy"; +static constexpr const char *descrMetricHwEnergy = "Energy consumed by the component"; +static constexpr const char *unitMetricHwEnergy = "J"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwEnergy( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricHwEnergy, descrMetricHwEnergy, unitMetricHwEnergy); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwEnergy( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricHwEnergy, descrMetricHwEnergy, unitMetricHwEnergy); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwEnergy( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricHwEnergy, descrMetricHwEnergy, + unitMetricHwEnergy); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwEnergy( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricHwEnergy, descrMetricHwEnergy, + unitMetricHwEnergy); +} + +/** + * Number of errors encountered by the component + *

        + * counter + */ +static constexpr const char *kMetricHwErrors = "metric.hw.errors"; +static constexpr const char *descrMetricHwErrors = "Number of errors encountered by the component"; +static constexpr const char *unitMetricHwErrors = "{error}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwErrors( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricHwErrors, descrMetricHwErrors, unitMetricHwErrors); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricHwErrors, descrMetricHwErrors, unitMetricHwErrors); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwErrors( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricHwErrors, descrMetricHwErrors, + unitMetricHwErrors); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricHwErrors, descrMetricHwErrors, + unitMetricHwErrors); +} + +/** + * Instantaneous power consumed by the component + *

        + * It is recommended to report @code hw.energy @endcode instead of @code hw.power @endcode when + * possible.

        gauge + */ +static constexpr const char *kMetricHwPower = "metric.hw.power"; +static constexpr const char *descrMetricHwPower = "Instantaneous power consumed by the component"; +static constexpr const char *unitMetricHwPower = "W"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +/** + * Operational status: @code 1 @endcode (true) or @code 0 @endcode (false) for each of the possible + * states

        + * @code hw.status @endcode is currently specified as an UpDownCounter but would ideally be + * represented using a StateSet + * as defined in OpenMetrics. This semantic convention will be updated once StateSet is + * specified in OpenTelemetry. This planned change is not expected to have any consequence on the + * way users query their timeseries backend to retrieve the values of @code hw.status @endcode over + * time.

        updowncounter + */ +static constexpr const char *kMetricHwStatus = "metric.hw.status"; +static constexpr const char *descrMetricHwStatus = + "Operational status: `1` (true) or `0` (false) for each of the possible states"; +static constexpr const char *unitMetricHwStatus = "1"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwStatus, descrMetricHwStatus, unitMetricHwStatus); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwStatus, descrMetricHwStatus, unitMetricHwStatus); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHwStatus, descrMetricHwStatus, + unitMetricHwStatus); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHwStatus, descrMetricHwStatus, + unitMetricHwStatus); +} + +} // namespace hw +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_attributes.h new file mode 100644 index 00000000000..ba40b454098 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_attributes.h @@ -0,0 +1,234 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace k8s +{ + +/** + * The name of the cluster. + */ +static constexpr const char *kK8sClusterName = "k8s.cluster.name"; + +/** + * A pseudo-ID for the cluster, set to the UID of the @code kube-system @endcode namespace. + *

        + * K8s doesn't have support for obtaining a cluster ID. If this is ever + * added, we will recommend collecting the @code k8s.cluster.uid @endcode through the + * official APIs. In the meantime, we are able to use the @code uid @endcode of the + * @code kube-system @endcode namespace as a proxy for cluster ID. Read on for the + * rationale. + *

        + * Every object created in a K8s cluster is assigned a distinct UID. The + * @code kube-system @endcode namespace is used by Kubernetes itself and will exist + * for the lifetime of the cluster. Using the @code uid @endcode of the @code kube-system @endcode + * namespace is a reasonable proxy for the K8s ClusterID as it will only + * change if the cluster is rebuilt. Furthermore, Kubernetes UIDs are + * UUIDs as standardized by + * ISO/IEC 9834-8 and ITU-T + * X.667. Which states:

        If generated according to one of the mechanisms defined + * in Rec. ITU-T X.667 | ISO/IEC 9834-8, a UUID is either guaranteed to be different from all other + * UUIDs generated before 3603 A.D., or is extremely likely to be different (depending on the + * mechanism chosen).
        + * + *

        + * Therefore, UIDs between clusters should be extremely unlikely to + * conflict. + */ +static constexpr const char *kK8sClusterUid = "k8s.cluster.uid"; + +/** + * The name of the Container from Pod specification, must be unique within a Pod. Container runtime + * usually uses different globally unique name (@code container.name @endcode). + */ +static constexpr const char *kK8sContainerName = "k8s.container.name"; + +/** + * Number of times the container was restarted. This attribute can be used to identify a particular + * container (running or stopped) within a container spec. + */ +static constexpr const char *kK8sContainerRestartCount = "k8s.container.restart_count"; + +/** + * Last terminated reason of the Container. + */ +static constexpr const char *kK8sContainerStatusLastTerminatedReason = + "k8s.container.status.last_terminated_reason"; + +/** + * The name of the CronJob. + */ +static constexpr const char *kK8sCronjobName = "k8s.cronjob.name"; + +/** + * The UID of the CronJob. + */ +static constexpr const char *kK8sCronjobUid = "k8s.cronjob.uid"; + +/** + * The name of the DaemonSet. + */ +static constexpr const char *kK8sDaemonsetName = "k8s.daemonset.name"; + +/** + * The UID of the DaemonSet. + */ +static constexpr const char *kK8sDaemonsetUid = "k8s.daemonset.uid"; + +/** + * The name of the Deployment. + */ +static constexpr const char *kK8sDeploymentName = "k8s.deployment.name"; + +/** + * The UID of the Deployment. + */ +static constexpr const char *kK8sDeploymentUid = "k8s.deployment.uid"; + +/** + * The name of the Job. + */ +static constexpr const char *kK8sJobName = "k8s.job.name"; + +/** + * The UID of the Job. + */ +static constexpr const char *kK8sJobUid = "k8s.job.uid"; + +/** + * The name of the namespace that the pod is running in. + */ +static constexpr const char *kK8sNamespaceName = "k8s.namespace.name"; + +/** + * The name of the Node. + */ +static constexpr const char *kK8sNodeName = "k8s.node.name"; + +/** + * The UID of the Node. + */ +static constexpr const char *kK8sNodeUid = "k8s.node.uid"; + +/** + * The annotation key-value pairs placed on the Pod, the @code @endcode being the annotation + * name, the value being the annotation value. + */ +static constexpr const char *kK8sPodAnnotation = "k8s.pod.annotation"; + +/** + * The label key-value pairs placed on the Pod, the @code @endcode being the label name, the + * value being the label value. + */ +static constexpr const char *kK8sPodLabel = "k8s.pod.label"; + +/** + * Deprecated, use @code k8s.pod.label @endcode instead. + *

        + * @deprecated + * Replaced by @code k8s.pod.label @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kK8sPodLabels = "k8s.pod.labels"; + +/** + * The name of the Pod. + */ +static constexpr const char *kK8sPodName = "k8s.pod.name"; + +/** + * The UID of the Pod. + */ +static constexpr const char *kK8sPodUid = "k8s.pod.uid"; + +/** + * 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 StatefulSet. + */ +static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; + +/** + * The UID of the StatefulSet. + */ +static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; + +/** + * The name of the K8s volume. + */ +static constexpr const char *kK8sVolumeName = "k8s.volume.name"; + +/** + * The type of the K8s volume. + */ +static constexpr const char *kK8sVolumeType = "k8s.volume.type"; + +namespace K8sVolumeTypeValues +{ +/** + * A persistentVolumeClaim + * volume + */ +static constexpr const char *kPersistentVolumeClaim = "persistentVolumeClaim"; + +/** + * A configMap + * volume + */ +static constexpr const char *kConfigMap = "configMap"; + +/** + * A downwardAPI + * volume + */ +static constexpr const char *kDownwardApi = "downwardAPI"; + +/** + * An emptyDir + * volume + */ +static constexpr const char *kEmptyDir = "emptyDir"; + +/** + * A secret + * volume + */ +static constexpr const char *kSecret = "secret"; + +/** + * A local + * volume + */ +static constexpr const char *kLocal = "local"; + +} // namespace K8sVolumeTypeValues + +} // namespace k8s +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_metrics.h new file mode 100644 index 00000000000..2753ba4be13 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_metrics.h @@ -0,0 +1,273 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace k8s +{ + +/** + * Total CPU time consumed + *

        + * Total CPU time consumed by the specific Node on all available CPU cores + *

        + * counter + */ +static constexpr const char *kMetricK8sNodeCpuTime = "metric.k8s.node.cpu.time"; +static constexpr const char *descrMetricK8sNodeCpuTime = "Total CPU time consumed"; +static constexpr const char *unitMetricK8sNodeCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricK8sNodeCpuTime, descrMetricK8sNodeCpuTime, + unitMetricK8sNodeCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sNodeCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricK8sNodeCpuTime, descrMetricK8sNodeCpuTime, + unitMetricK8sNodeCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricK8sNodeCpuTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricK8sNodeCpuTime, descrMetricK8sNodeCpuTime, + unitMetricK8sNodeCpuTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeCpuTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricK8sNodeCpuTime, descrMetricK8sNodeCpuTime, + unitMetricK8sNodeCpuTime); +} + +/** + * Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + *

        + * CPU usage of the specific Node on all available CPU cores, averaged over the sample window + *

        + * gauge + */ +static constexpr const char *kMetricK8sNodeCpuUsage = "metric.k8s.node.cpu.usage"; +static constexpr const char *descrMetricK8sNodeCpuUsage = + "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; +static constexpr const char *unitMetricK8sNodeCpuUsage = "{cpu}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sNodeCpuUsage, descrMetricK8sNodeCpuUsage, + unitMetricK8sNodeCpuUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sNodeCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sNodeCpuUsage, descrMetricK8sNodeCpuUsage, + unitMetricK8sNodeCpuUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeCpuUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sNodeCpuUsage, descrMetricK8sNodeCpuUsage, + unitMetricK8sNodeCpuUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeCpuUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricK8sNodeCpuUsage, descrMetricK8sNodeCpuUsage, + unitMetricK8sNodeCpuUsage); +} + +/** + * Memory usage of the Node + *

        + * Total memory usage of the Node + *

        + * gauge + */ +static constexpr const char *kMetricK8sNodeMemoryUsage = "metric.k8s.node.memory.usage"; +static constexpr const char *descrMetricK8sNodeMemoryUsage = "Memory usage of the Node"; +static constexpr const char *unitMetricK8sNodeMemoryUsage = "By"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeMemoryUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, + unitMetricK8sNodeMemoryUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sNodeMemoryUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, + unitMetricK8sNodeMemoryUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, + unitMetricK8sNodeMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricK8sNodeMemoryUsage, descrMetricK8sNodeMemoryUsage, unitMetricK8sNodeMemoryUsage); +} + +/** + * Total CPU time consumed + *

        + * Total CPU time consumed by the specific Pod on all available CPU cores + *

        + * counter + */ +static constexpr const char *kMetricK8sPodCpuTime = "metric.k8s.pod.cpu.time"; +static constexpr const char *descrMetricK8sPodCpuTime = "Total CPU time consumed"; +static constexpr const char *unitMetricK8sPodCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricK8sPodCpuTime, descrMetricK8sPodCpuTime, + unitMetricK8sPodCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricK8sPodCpuTime, descrMetricK8sPodCpuTime, + unitMetricK8sPodCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricK8sPodCpuTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricK8sPodCpuTime, descrMetricK8sPodCpuTime, + unitMetricK8sPodCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricK8sPodCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricK8sPodCpuTime, descrMetricK8sPodCpuTime, + unitMetricK8sPodCpuTime); +} + +/** + * Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + *

        + * CPU usage of the specific Pod on all available CPU cores, averaged over the sample window + *

        + * gauge + */ +static constexpr const char *kMetricK8sPodCpuUsage = "metric.k8s.pod.cpu.usage"; +static constexpr const char *descrMetricK8sPodCpuUsage = + "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; +static constexpr const char *unitMetricK8sPodCpuUsage = "{cpu}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sPodCpuUsage, descrMetricK8sPodCpuUsage, + unitMetricK8sPodCpuUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sPodCpuUsage, descrMetricK8sPodCpuUsage, + unitMetricK8sPodCpuUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricK8sPodCpuUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sPodCpuUsage, descrMetricK8sPodCpuUsage, + unitMetricK8sPodCpuUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodCpuUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricK8sPodCpuUsage, descrMetricK8sPodCpuUsage, + unitMetricK8sPodCpuUsage); +} + +/** + * Memory usage of the Pod + *

        + * Total memory usage of the Pod + *

        + * gauge + */ +static constexpr const char *kMetricK8sPodMemoryUsage = "metric.k8s.pod.memory.usage"; +static constexpr const char *descrMetricK8sPodMemoryUsage = "Memory usage of the Pod"; +static constexpr const char *unitMetricK8sPodMemoryUsage = "By"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodMemoryUsage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricK8sPodMemoryUsage, descrMetricK8sPodMemoryUsage, + unitMetricK8sPodMemoryUsage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricK8sPodMemoryUsage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricK8sPodMemoryUsage, descrMetricK8sPodMemoryUsage, + unitMetricK8sPodMemoryUsage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricK8sPodMemoryUsage, descrMetricK8sPodMemoryUsage, + unitMetricK8sPodMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricK8sPodMemoryUsage, descrMetricK8sPodMemoryUsage, + unitMetricK8sPodMemoryUsage); +} + +} // namespace k8s +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/linux_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/linux_attributes.h new file mode 100644 index 00000000000..024e2b60e6f --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/linux_attributes.h @@ -0,0 +1,43 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace linux +{ + +/** + * The Linux Slab memory state + */ +static constexpr const char *kLinuxMemorySlabState = "linux.memory.slab.state"; + +namespace LinuxMemorySlabStateValues +{ +/** + * none + */ +static constexpr const char *kReclaimable = "reclaimable"; + +/** + * none + */ +static constexpr const char *kUnreclaimable = "unreclaimable"; + +} // namespace LinuxMemorySlabStateValues + +} // namespace linux +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/log_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/log_attributes.h new file mode 100644 index 00000000000..f9224f1bba4 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/log_attributes.h @@ -0,0 +1,82 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace log +{ + +/** + * The basename of the file. + */ +static constexpr const char *kLogFileName = "log.file.name"; + +/** + * The basename of the file, with symlinks resolved. + */ +static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; + +/** + * The full path to the file. + */ +static constexpr const char *kLogFilePath = "log.file.path"; + +/** + * The full path to the file, with symlinks resolved. + */ +static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; + +/** + * The stream associated with the log. See below for a list of well-known values. + */ +static constexpr const char *kLogIostream = "log.iostream"; + +/** + * The complete original Log Record. + *

        + * This value MAY be added when processing a Log Record which was originally transmitted as a string + * or equivalent data type AND the Body field of the Log Record does not contain the same value. + * (e.g. a syslog or a log record read from a file.) + */ +static constexpr const char *kLogRecordOriginal = "log.record.original"; + +/** + * A unique identifier for the Log Record. + *

        + * If an id is provided, other log records with the same id will be considered duplicates and can be + * removed safely. This means, that two distinguishable log records MUST have different values. The + * id MAY be an Universally Unique Lexicographically Sortable + * Identifier (ULID), but other identifiers (e.g. UUID) may be used as needed. + */ +static constexpr const char *kLogRecordUid = "log.record.uid"; + +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 log +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/message_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/message_attributes.h new file mode 100644 index 00000000000..508a1e58f64 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/message_attributes.h @@ -0,0 +1,74 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace message +{ + +/** + * Deprecated, use @code rpc.message.compressed_size @endcode instead. + *

        + * @deprecated + * Replaced by @code rpc.message.compressed_size @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageCompressedSize = "message.compressed_size"; + +/** + * Deprecated, use @code rpc.message.id @endcode instead. + *

        + * @deprecated + * Replaced by @code rpc.message.id @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageId = "message.id"; + +/** + * Deprecated, use @code rpc.message.type @endcode instead. + *

        + * @deprecated + * Replaced by @code rpc.message.type @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageType = "message.type"; + +/** + * Deprecated, use @code rpc.message.uncompressed_size @endcode instead. + *

        + * @deprecated + * Replaced by @code rpc.message.uncompressed_size @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; + +namespace MessageTypeValues +{ +/** + * none + */ +static constexpr const char *kSent = "SENT"; + +/** + * none + */ +static constexpr const char *kReceived = "RECEIVED"; + +} // namespace MessageTypeValues + +} // namespace message +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_attributes.h new file mode 100644 index 00000000000..4cf20365ab6 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_attributes.h @@ -0,0 +1,543 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace messaging +{ + +/** + * The number of messages sent, received, or processed in the scope of the batching operation. + *

        + * Instrumentations SHOULD NOT set @code messaging.batch.message_count @endcode on spans that + * operate with a single message. When a messaging client library supports both batch and + * single-message API for the same operation, instrumentations SHOULD use @code + * messaging.batch.message_count @endcode for batching APIs and SHOULD NOT use it for single-message + * APIs. + */ +static constexpr const char *kMessagingBatchMessageCount = "messaging.batch.message_count"; + +/** + * A unique identifier for the client that consumes or produces a message. + */ +static constexpr const char *kMessagingClientId = "messaging.client.id"; + +#if 0 +// Excluded attribute: +/** + * Deprecated, use @code messaging.client.id @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.id @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingClientId + = "messaging.client_id"; +#endif + +/** + * The name of the consumer group with which a consumer is associated. + *

        + * Semantic conventions for individual messaging systems SHOULD document whether @code + * messaging.consumer.group.name @endcode is applicable and what it means in the context of that + * system. + */ +static constexpr const char *kMessagingConsumerGroupName = "messaging.consumer.group.name"; + +/** + * 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"; + +/** + * The message destination name + *

        + * Destination name SHOULD uniquely identify a specific queue, topic or other entity within the + * broker. If the broker doesn't have such notion, the destination name SHOULD uniquely identify the + * broker. + */ +static constexpr const char *kMessagingDestinationName = "messaging.destination.name"; + +/** + * The identifier of the partition messages are sent to or received from, unique within the @code + * messaging.destination.name @endcode. + */ +static constexpr const char *kMessagingDestinationPartitionId = + "messaging.destination.partition.id"; + +/** + * The name of the destination subscription from which a message is consumed. + *

        + * Semantic conventions for individual messaging systems SHOULD document whether @code + * messaging.destination.subscription.name @endcode is applicable and what it means in the context + * of that system. + */ +static constexpr const char *kMessagingDestinationSubscriptionName = + "messaging.destination.subscription.name"; + +/** + * Low cardinality representation of the messaging destination name + *

        + * Destination names could be constructed from templates. An example would be a destination name + * involving a user name or product id. Although the destination name in this case is of high + * cardinality, the underlying template is of low cardinality and can be effectively used for + * grouping and aggregation. + */ +static constexpr const char *kMessagingDestinationTemplate = "messaging.destination.template"; + +/** + * 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"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * No replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * No replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; + +/** + * Deprecated, use @code messaging.consumer.group.name @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.consumer.group.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingEventhubsConsumerGroup = + "messaging.eventhubs.consumer.group"; + +/** + * The UTC epoch seconds at which the message has been accepted and stored in the entity. + */ +static constexpr const char *kMessagingEventhubsMessageEnqueuedTime = + "messaging.eventhubs.message.enqueued_time"; + +/** + * The ack deadline in seconds set for the modify ack deadline request. + */ +static constexpr const char *kMessagingGcpPubsubMessageAckDeadline = + "messaging.gcp_pubsub.message.ack_deadline"; + +/** + * The ack id for a given message. + */ +static constexpr const char *kMessagingGcpPubsubMessageAckId = + "messaging.gcp_pubsub.message.ack_id"; + +/** + * The delivery attempt for a given message. + */ +static constexpr const char *kMessagingGcpPubsubMessageDeliveryAttempt = + "messaging.gcp_pubsub.message.delivery_attempt"; + +/** + * The ordering key for a given message. If the attribute is not present, the message does not have + * an ordering key. + */ +static constexpr const char *kMessagingGcpPubsubMessageOrderingKey = + "messaging.gcp_pubsub.message.ordering_key"; + +/** + * Deprecated, use @code messaging.consumer.group.name @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.consumer.group.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; + +/** + * Deprecated, use @code messaging.destination.partition.id @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.destination.partition.id @endcode. + */ +OPENTELEMETRY_DEPRECATED +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 @endcode in that they're not unique. + * If the key is @code null @endcode, the attribute MUST NOT be set.

        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"; + +/** + * Deprecated, use @code messaging.kafka.offset @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.kafka.offset @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; + +/** + * A boolean that is true if the message is a tombstone. + */ +static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; + +/** + * The offset of a record in the corresponding Kafka partition. + */ +static constexpr const char *kMessagingKafkaOffset = "messaging.kafka.offset"; + +/** + * The size of the message body in bytes. + *

        + * 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 *kMessagingMessageBodySize = "messaging.message.body.size"; + +/** + * The conversation ID identifying the conversation to which the message belongs, represented as a + * string. Sometimes called "Correlation ID". + */ +static constexpr const char *kMessagingMessageConversationId = "messaging.message.conversation_id"; + +/** + * The size of the message body and metadata in bytes. + *

        + * 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 *kMessagingMessageId = "messaging.message.id"; + +/** + * Deprecated, use @code messaging.operation.type @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.operation.type @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingOperation = "messaging.operation"; + +/** + * The system-specific name of the messaging operation. + */ +static constexpr const char *kMessagingOperationName = "messaging.operation.name"; + +/** + * A string identifying the type of the messaging operation. + *

        + * If a custom value is used, it MUST be of low cardinality. + */ +static constexpr const char *kMessagingOperationType = "messaging.operation.type"; + +/** + * RabbitMQ message routing key. + */ +static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = + "messaging.rabbitmq.destination.routing_key"; + +/** + * RabbitMQ message delivery tag + */ +static constexpr const char *kMessagingRabbitmqMessageDeliveryTag = + "messaging.rabbitmq.message.delivery_tag"; + +/** + * Deprecated, use @code messaging.consumer.group.name @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.consumer.group.name @endcode on the consumer spans. No replacement + * for producer spans. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; + +/** + * Model of message consumption. This only applies to consumer spans. + */ +static constexpr const char *kMessagingRocketmqConsumptionModel = + "messaging.rocketmq.consumption_model"; + +/** + * The delay time level for delay message, which determines the message delay time. + */ +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. + */ +static constexpr const char *kMessagingRocketmqMessageGroup = "messaging.rocketmq.message.group"; + +/** + * Key(s) of message, another way to mark message besides message id. + */ +static constexpr const char *kMessagingRocketmqMessageKeys = "messaging.rocketmq.message.keys"; + +/** + * The secondary classifier of message besides topic. + */ +static constexpr const char *kMessagingRocketmqMessageTag = "messaging.rocketmq.message.tag"; + +/** + * Type of message. + */ +static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq.message.type"; + +/** + * Namespace of RocketMQ resources, resources in different namespaces are individual. + */ +static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; + +/** + * Deprecated, use @code messaging.destination.subscription.name @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.destination.subscription.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingServicebusDestinationSubscriptionName = + "messaging.servicebus.destination.subscription_name"; + +/** + * Describes the settlement + * type. + */ +static constexpr const char *kMessagingServicebusDispositionStatus = + "messaging.servicebus.disposition_status"; + +/** + * Number of deliveries that have been attempted for this message. + */ +static constexpr const char *kMessagingServicebusMessageDeliveryCount = + "messaging.servicebus.message.delivery_count"; + +/** + * The UTC epoch seconds at which the message has been accepted and stored in the entity. + */ +static constexpr const char *kMessagingServicebusMessageEnqueuedTime = + "messaging.servicebus.message.enqueued_time"; + +/** + * The messaging system as identified by the client instrumentation. + *

        + * The actual messaging system may differ from the one known by the client. For example, when using + * Kafka client libraries to communicate with Azure Event Hubs, the @code messaging.system @endcode + * is set to @code kafka @endcode based on the instrumentation's best knowledge. + */ +static constexpr const char *kMessagingSystem = "messaging.system"; + +namespace MessagingOperationTypeValues +{ +/** + * A message is created. "Create" spans always refer to a single message and are used to provide a + * unique creation context for messages in batch sending scenarios. + */ +static constexpr const char *kCreate = "create"; + +/** + * One or more messages are provided for sending to an intermediary. If a single message is sent, + * the context of the "Send" span can be used as the creation context and no "Create" span needs to + * be created. + */ +static constexpr const char *kSend = "send"; + +/** + * One or more messages are requested by a consumer. This operation refers to pull-based scenarios, + * where consumers explicitly call methods of messaging SDKs to receive messages. + */ +static constexpr const char *kReceive = "receive"; + +/** + * One or more messages are processed by a consumer. + */ +static constexpr const char *kProcess = "process"; + +/** + * One or more messages are settled. + */ +static constexpr const char *kSettle = "settle"; + +/** + * Deprecated. Use @code process @endcode instead. + *

        + * @deprecated + * Replaced by @code process @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDeliver = "deliver"; + +/** + * Deprecated. Use @code send @endcode instead. + *

        + * @deprecated + * Replaced by @code send @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kPublish = "publish"; + +} // namespace MessagingOperationTypeValues + +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 + */ +static constexpr const char *kNormal = "normal"; + +/** + * FIFO message + */ +static constexpr const char *kFifo = "fifo"; + +/** + * Delay message + */ +static constexpr const char *kDelay = "delay"; + +/** + * Transaction message + */ +static constexpr const char *kTransaction = "transaction"; + +} // namespace MessagingRocketmqMessageTypeValues + +namespace MessagingServicebusDispositionStatusValues +{ +/** + * Message is completed + */ +static constexpr const char *kComplete = "complete"; + +/** + * Message is abandoned + */ +static constexpr const char *kAbandon = "abandon"; + +/** + * Message is sent to dead letter queue + */ +static constexpr const char *kDeadLetter = "dead_letter"; + +/** + * Message is deferred + */ +static constexpr const char *kDefer = "defer"; + +} // namespace MessagingServicebusDispositionStatusValues + +namespace MessagingSystemValues +{ +/** + * Apache ActiveMQ + */ +static constexpr const char *kActivemq = "activemq"; + +/** + * Amazon Simple Queue Service (SQS) + */ +static constexpr const char *kAwsSqs = "aws_sqs"; + +/** + * Azure Event Grid + */ +static constexpr const char *kEventgrid = "eventgrid"; + +/** + * Azure Event Hubs + */ +static constexpr const char *kEventhubs = "eventhubs"; + +/** + * Azure Service Bus + */ +static constexpr const char *kServicebus = "servicebus"; + +/** + * Google Cloud Pub/Sub + */ +static constexpr const char *kGcpPubsub = "gcp_pubsub"; + +/** + * Java Message Service + */ +static constexpr const char *kJms = "jms"; + +/** + * Apache Kafka + */ +static constexpr const char *kKafka = "kafka"; + +/** + * RabbitMQ + */ +static constexpr const char *kRabbitmq = "rabbitmq"; + +/** + * Apache RocketMQ + */ +static constexpr const char *kRocketmq = "rocketmq"; + +/** + * Apache Pulsar + */ +static constexpr const char *kPulsar = "pulsar"; + +} // namespace MessagingSystemValues + +} // namespace messaging +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_metrics.h new file mode 100644 index 00000000000..9c29fb86b34 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_metrics.h @@ -0,0 +1,449 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace messaging +{ + +/** + * Number of messages that were delivered to the application. + *

        + * Records the number of messages pulled from the broker or number of messages dispatched to the + * application in push-based scenarios. The metric SHOULD be reported once per message delivery. For + * example, if receiving and processing operations are both instrumented for a single message + * delivery, this counter is incremented when the message is received and not reported when it is + * processed.

        counter + */ +static constexpr const char *kMetricMessagingClientConsumedMessages = + "metric.messaging.client.consumed.messages"; +static constexpr const char *descrMetricMessagingClientConsumedMessages = + "Number of messages that were delivered to the application."; +static constexpr const char *unitMetricMessagingClientConsumedMessages = "{message}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingClientConsumedMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingClientConsumedMessages, + descrMetricMessagingClientConsumedMessages, + unitMetricMessagingClientConsumedMessages); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingClientConsumedMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingClientConsumedMessages, + descrMetricMessagingClientConsumedMessages, + unitMetricMessagingClientConsumedMessages); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingClientConsumedMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingClientConsumedMessages, + descrMetricMessagingClientConsumedMessages, + unitMetricMessagingClientConsumedMessages); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingClientConsumedMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingClientConsumedMessages, + descrMetricMessagingClientConsumedMessages, + unitMetricMessagingClientConsumedMessages); +} + +/** + * Duration of messaging operation initiated by a producer or consumer client. + *

        + * This metric SHOULD NOT be used to report processing duration - processing duration is reported in + * @code messaging.process.duration @endcode metric.

        histogram + */ +static constexpr const char *kMetricMessagingClientOperationDuration = + "metric.messaging.client.operation.duration"; +static constexpr const char *descrMetricMessagingClientOperationDuration = + "Duration of messaging operation initiated by a producer or consumer client."; +static constexpr const char *unitMetricMessagingClientOperationDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricMessagingClientOperationDuration, + descrMetricMessagingClientOperationDuration, + unitMetricMessagingClientOperationDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingClientOperationDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricMessagingClientOperationDuration, + descrMetricMessagingClientOperationDuration, + unitMetricMessagingClientOperationDuration); +} + +/** + * Deprecated. Use @code messaging.client.sent.messages @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.sent.messages @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingClientPublishedMessages = + "metric.messaging.client.published.messages"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingClientPublishedMessages = + "Deprecated. Use `messaging.client.sent.messages` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingClientPublishedMessages = "{message}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingClientPublishedMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingClientPublishedMessages, + descrMetricMessagingClientPublishedMessages, + unitMetricMessagingClientPublishedMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingClientPublishedMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingClientPublishedMessages, + descrMetricMessagingClientPublishedMessages, + unitMetricMessagingClientPublishedMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingClientPublishedMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingClientPublishedMessages, + descrMetricMessagingClientPublishedMessages, + unitMetricMessagingClientPublishedMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingClientPublishedMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingClientPublishedMessages, + descrMetricMessagingClientPublishedMessages, + unitMetricMessagingClientPublishedMessages); +} + +/** + * Number of messages producer attempted to send to the broker. + *

        + * This metric MUST NOT count messages that were created but haven't yet been sent. + *

        + * counter + */ +static constexpr const char *kMetricMessagingClientSentMessages = + "metric.messaging.client.sent.messages"; +static constexpr const char *descrMetricMessagingClientSentMessages = + "Number of messages producer attempted to send to the broker."; +static constexpr const char *unitMetricMessagingClientSentMessages = "{message}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingClientSentMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingClientSentMessages, + descrMetricMessagingClientSentMessages, + unitMetricMessagingClientSentMessages); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingClientSentMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingClientSentMessages, + descrMetricMessagingClientSentMessages, + unitMetricMessagingClientSentMessages); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingClientSentMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingClientSentMessages, + descrMetricMessagingClientSentMessages, + unitMetricMessagingClientSentMessages); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingClientSentMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingClientSentMessages, + descrMetricMessagingClientSentMessages, + unitMetricMessagingClientSentMessages); +} + +/** + * Duration of processing operation. + *

        + * This metric MUST be reported for operations with @code messaging.operation.type @endcode that + * matches @code process @endcode.

        histogram + */ +static constexpr const char *kMetricMessagingProcessDuration = "metric.messaging.process.duration"; +static constexpr const char *descrMetricMessagingProcessDuration = + "Duration of processing operation."; +static constexpr const char *unitMetricMessagingProcessDuration = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingProcessDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricMessagingProcessDuration, + descrMetricMessagingProcessDuration, + unitMetricMessagingProcessDuration); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingProcessDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricMessagingProcessDuration, + descrMetricMessagingProcessDuration, + unitMetricMessagingProcessDuration); +} + +/** + * Deprecated. Use @code messaging.client.consumed.messages @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.consumed.messages @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingProcessMessages = "metric.messaging.process.messages"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingProcessMessages = + "Deprecated. Use `messaging.client.consumed.messages` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingProcessMessages = "{message}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingProcessMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingProcessMessages, + descrMetricMessagingProcessMessages, + unitMetricMessagingProcessMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingProcessMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingProcessMessages, + descrMetricMessagingProcessMessages, + unitMetricMessagingProcessMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingProcessMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingProcessMessages, + descrMetricMessagingProcessMessages, + unitMetricMessagingProcessMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingProcessMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingProcessMessages, + descrMetricMessagingProcessMessages, + unitMetricMessagingProcessMessages); +} + +/** + * Deprecated. Use @code messaging.client.operation.duration @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.operation.duration @endcode. + *

        + * histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingPublishDuration = "metric.messaging.publish.duration"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingPublishDuration = + "Deprecated. Use `messaging.client.operation.duration` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingPublishDuration = "s"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingPublishDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricMessagingPublishDuration, + descrMetricMessagingPublishDuration, + unitMetricMessagingPublishDuration); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingPublishDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricMessagingPublishDuration, + descrMetricMessagingPublishDuration, + unitMetricMessagingPublishDuration); +} + +/** + * Deprecated. Use @code messaging.client.produced.messages @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.produced.messages @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingPublishMessages = "metric.messaging.publish.messages"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingPublishMessages = + "Deprecated. Use `messaging.client.produced.messages` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingPublishMessages = "{message}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingPublishMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingPublishMessages, + descrMetricMessagingPublishMessages, + unitMetricMessagingPublishMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingPublishMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingPublishMessages, + descrMetricMessagingPublishMessages, + unitMetricMessagingPublishMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingPublishMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingPublishMessages, + descrMetricMessagingPublishMessages, + unitMetricMessagingPublishMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingPublishMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingPublishMessages, + descrMetricMessagingPublishMessages, + unitMetricMessagingPublishMessages); +} + +/** + * Deprecated. Use @code messaging.client.operation.duration @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.operation.duration @endcode. + *

        + * histogram + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingReceiveDuration = "metric.messaging.receive.duration"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingReceiveDuration = + "Deprecated. Use `messaging.client.operation.duration` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingReceiveDuration = "s"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingReceiveDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricMessagingReceiveDuration, + descrMetricMessagingReceiveDuration, + unitMetricMessagingReceiveDuration); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingReceiveDuration(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricMessagingReceiveDuration, + descrMetricMessagingReceiveDuration, + unitMetricMessagingReceiveDuration); +} + +/** + * Deprecated. Use @code messaging.client.consumed.messages @endcode instead. + *

        + * @deprecated + * Replaced by @code messaging.client.consumed.messages @endcode. + *

        + * counter + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMetricMessagingReceiveMessages = "metric.messaging.receive.messages"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *descrMetricMessagingReceiveMessages = + "Deprecated. Use `messaging.client.consumed.messages` instead."; +OPENTELEMETRY_DEPRECATED +static constexpr const char *unitMetricMessagingReceiveMessages = "{message}"; + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncInt64MetricMessagingReceiveMessages(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricMessagingReceiveMessages, + descrMetricMessagingReceiveMessages, + unitMetricMessagingReceiveMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::unique_ptr> +CreateSyncDoubleMetricMessagingReceiveMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricMessagingReceiveMessages, + descrMetricMessagingReceiveMessages, + unitMetricMessagingReceiveMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncInt64MetricMessagingReceiveMessages(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricMessagingReceiveMessages, + descrMetricMessagingReceiveMessages, + unitMetricMessagingReceiveMessages); +} + +OPENTELEMETRY_DEPRECATED +static inline nostd::shared_ptr +CreateAsyncDoubleMetricMessagingReceiveMessages(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricMessagingReceiveMessages, + descrMetricMessagingReceiveMessages, + unitMetricMessagingReceiveMessages); +} + +} // namespace messaging +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/net_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/net_attributes.h new file mode 100644 index 00000000000..95622992235 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/net_attributes.h @@ -0,0 +1,209 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace net +{ + +/** + * Deprecated, use @code network.local.address @endcode. + *

        + * @deprecated + * Replaced by @code network.local.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostIp = "net.host.ip"; + +/** + * Deprecated, use @code server.address @endcode. + *

        + * @deprecated + * Replaced by @code server.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostName = "net.host.name"; + +/** + * Deprecated, use @code server.port @endcode. + *

        + * @deprecated + * Replaced by @code server.port @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostPort = "net.host.port"; + +/** + * Deprecated, use @code network.peer.address @endcode. + *

        + * @deprecated + * Replaced by @code network.peer.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetPeerIp = "net.peer.ip"; + +/** + * Deprecated, use @code server.address @endcode on client spans and @code client.address @endcode + * on server spans.

        + * @deprecated + * Replaced by @code server.address @endcode on client spans and @code client.address @endcode on + * server spans. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetPeerName = "net.peer.name"; + +/** + * Deprecated, use @code server.port @endcode on client spans and @code client.port @endcode on + * server spans.

        + * @deprecated + * Replaced by @code server.port @endcode on client spans and @code client.port @endcode on server + * spans. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetPeerPort = "net.peer.port"; + +/** + * Deprecated, use @code network.protocol.name @endcode. + *

        + * @deprecated + * Replaced by @code network.protocol.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetProtocolName = "net.protocol.name"; + +/** + * Deprecated, use @code network.protocol.version @endcode. + *

        + * @deprecated + * Replaced by @code network.protocol.version @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetProtocolVersion = "net.protocol.version"; + +/** + * Deprecated, use @code network.transport @endcode and @code network.type @endcode. + *

        + * @deprecated + * Split to @code network.transport @endcode and @code network.type @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockFamily = "net.sock.family"; + +/** + * Deprecated, use @code network.local.address @endcode. + *

        + * @deprecated + * Replaced by @code network.local.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockHostAddr = "net.sock.host.addr"; + +/** + * Deprecated, use @code network.local.port @endcode. + *

        + * @deprecated + * Replaced by @code network.local.port @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockHostPort = "net.sock.host.port"; + +/** + * Deprecated, use @code network.peer.address @endcode. + *

        + * @deprecated + * Replaced by @code network.peer.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerAddr = "net.sock.peer.addr"; + +/** + * Deprecated, no replacement at this time. + *

        + * @deprecated + * Removed. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerName = "net.sock.peer.name"; + +/** + * Deprecated, use @code network.peer.port @endcode. + *

        + * @deprecated + * Replaced by @code network.peer.port @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; + +/** + * Deprecated, use @code network.transport @endcode. + *

        + * @deprecated + * Replaced by @code network.transport @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetTransport = "net.transport"; + +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 +{ +/** + * none + */ +static constexpr const char *kIpTcp = "ip_tcp"; + +/** + * none + */ +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 net +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/network_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/network_attributes.h new file mode 100644 index 00000000000..ea855c57354 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/network_attributes.h @@ -0,0 +1,308 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace network +{ + +/** + * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. + */ +static constexpr const char *kNetworkCarrierIcc = "network.carrier.icc"; + +/** + * The mobile carrier country code. + */ +static constexpr const char *kNetworkCarrierMcc = "network.carrier.mcc"; + +/** + * 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"; + +/** + * The network IO operation direction. + */ +static constexpr const char *kNetworkIoDirection = "network.io.direction"; + +/** + * Local address of the network connection - IP address or Unix domain socket name. + */ +static constexpr const char *kNetworkLocalAddress = "network.local.address"; + +/** + * Local port number of the network connection. + */ +static constexpr const char *kNetworkLocalPort = "network.local.port"; + +/** + * Peer address of the network connection - IP address or Unix domain socket name. + */ +static constexpr const char *kNetworkPeerAddress = "network.peer.address"; + +/** + * Peer port number of the network connection. + */ +static constexpr const char *kNetworkPeerPort = "network.peer.port"; + +/** + * OSI application layer or non-OSI + * equivalent.

        The value SHOULD be normalized to lowercase. + */ +static constexpr const char *kNetworkProtocolName = "network.protocol.name"; + +/** + * The actual version of the protocol used for network communication. + *

        + * If protocol version is subject to negotiation (for example using ALPN), this attribute SHOULD be set to the + * negotiated version. If the actual protocol version is not known, this attribute SHOULD NOT be + * set. + */ +static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; + +/** + * OSI transport layer or inter-process communication + * method.

        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 *kNetworkTransport = "network.transport"; + +/** + * OSI network layer or non-OSI equivalent. + *

        + * The value SHOULD be normalized to lowercase. + */ +static constexpr const char *kNetworkType = "network.type"; + +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 NetworkConnectionTypeValues +{ +/** + * none + */ +static constexpr const char *kWifi = "wifi"; + +/** + * none + */ +static constexpr const char *kWired = "wired"; + +/** + * none + */ +static constexpr const char *kCell = "cell"; + +/** + * none + */ +static constexpr const char *kUnavailable = "unavailable"; + +/** + * none + */ +static constexpr const char *kUnknown = "unknown"; + +} // namespace NetworkConnectionTypeValues + +namespace NetworkIoDirectionValues +{ +/** + * none + */ +static constexpr const char *kTransmit = "transmit"; + +/** + * none + */ +static constexpr const char *kReceive = "receive"; + +} // namespace NetworkIoDirectionValues + +namespace NetworkTransportValues +{ +/** + * TCP + */ +static constexpr const char *kTcp = "tcp"; + +/** + * UDP + */ +static constexpr const char *kUdp = "udp"; + +/** + * Named or anonymous pipe. + */ +static constexpr const char *kPipe = "pipe"; + +/** + * Unix domain socket + */ +static constexpr const char *kUnix = "unix"; + +/** + * QUIC + */ +static constexpr const char *kQuic = "quic"; + +} // namespace NetworkTransportValues + +namespace NetworkTypeValues +{ +/** + * IPv4 + */ +static constexpr const char *kIpv4 = "ipv4"; + +/** + * IPv6 + */ +static constexpr const char *kIpv6 = "ipv6"; + +} // namespace NetworkTypeValues + +} // namespace network +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/oci_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/oci_attributes.h new file mode 100644 index 00000000000..ade92d35c89 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/oci_attributes.h @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace oci +{ + +/** + * The digest of the OCI image manifest. For container images specifically is the digest by which + * the container image is known.

        Follows OCI Image Manifest + * Specification, and specifically the Digest + * property. An example can be found in Example Image + * Manifest. + */ +static constexpr const char *kOciManifestDigest = "oci.manifest.digest"; + +} // namespace oci +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/opentracing_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/opentracing_attributes.h new file mode 100644 index 00000000000..159645e76b4 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/opentracing_attributes.h @@ -0,0 +1,45 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace opentracing +{ + +/** + * Parent-child Reference type + *

        + * The causal relationship between a child Span and a parent Span. + */ +static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; + +namespace OpentracingRefTypeValues +{ +/** + * The parent Span depends on the child Span in some capacity + */ +static constexpr const char *kChildOf = "child_of"; + +/** + * The parent Span doesn't depend in any way on the result of the child Span + */ +static constexpr const char *kFollowsFrom = "follows_from"; + +} // namespace OpentracingRefTypeValues + +} // namespace opentracing +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/os_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/os_attributes.h new file mode 100644 index 00000000000..807deaaf92e --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/os_attributes.h @@ -0,0 +1,110 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace os +{ + +/** + * Unique identifier for a particular build or compilation of the operating system. + */ +static constexpr const char *kOsBuildId = "os.build_id"; + +/** + * Human readable (not intended to be parsed) OS version information, like e.g. reported by @code + * ver @endcode or @code lsb_release -a @endcode commands. + */ +static constexpr const char *kOsDescription = "os.description"; + +/** + * Human readable operating system name. + */ +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. + */ +static constexpr const char *kOsVersion = "os.version"; + +namespace OsTypeValues +{ +/** + * Microsoft Windows + */ +static constexpr const char *kWindows = "windows"; + +/** + * Linux + */ +static constexpr const char *kLinux = "linux"; + +/** + * Apple Darwin + */ +static constexpr const char *kDarwin = "darwin"; + +/** + * FreeBSD + */ +static constexpr const char *kFreebsd = "freebsd"; + +/** + * NetBSD + */ +static constexpr const char *kNetbsd = "netbsd"; + +/** + * OpenBSD + */ +static constexpr const char *kOpenbsd = "openbsd"; + +/** + * DragonFly BSD + */ +static constexpr const char *kDragonflybsd = "dragonflybsd"; + +/** + * HP-UX (Hewlett Packard Unix) + */ +static constexpr const char *kHpux = "hpux"; + +/** + * AIX (Advanced Interactive eXecutive) + */ +static constexpr const char *kAix = "aix"; + +/** + * SunOS, Oracle Solaris + */ +static constexpr const char *kSolaris = "solaris"; + +/** + * IBM z/OS + */ +static constexpr const char *kZOs = "z_os"; + +} // namespace OsTypeValues + +} // namespace os +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_attributes.h new file mode 100644 index 00000000000..e3a32510050 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_attributes.h @@ -0,0 +1,77 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace otel +{ + +/** + * Deprecated. Use the @code otel.scope.name @endcode attribute + *

        + * @deprecated + * Use the @code otel.scope.name @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kOtelLibraryName = "otel.library.name"; + +/** + * Deprecated. Use the @code otel.scope.version @endcode attribute. + *

        + * @deprecated + * Use the @code otel.scope.version @endcode attribute. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kOtelLibraryVersion = "otel.library.version"; + +/** + * The name of the instrumentation scope - (@code InstrumentationScope.Name @endcode in OTLP). + */ +static constexpr const char *kOtelScopeName = "otel.scope.name"; + +/** + * The version of the instrumentation scope - (@code InstrumentationScope.Version @endcode in OTLP). + */ +static constexpr const char *kOtelScopeVersion = "otel.scope.version"; + +/** + * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code is UNSET. + */ +static constexpr const char *kOtelStatusCode = "otel.status_code"; + +/** + * Description of the Status if it has a value, otherwise not set. + */ +static constexpr const char *kOtelStatusDescription = "otel.status_description"; + +namespace OtelStatusCodeValues +{ +/** + * The operation has been validated by an Application developer or Operator to have completed + * successfully. + */ +static constexpr const char *kOk = "OK"; + +/** + * The operation contains an error. + */ +static constexpr const char *kError = "ERROR"; + +} // namespace OtelStatusCodeValues + +} // namespace otel +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/other_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/other_attributes.h new file mode 100644 index 00000000000..bc6d26ef164 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/other_attributes.h @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace other +{ + +/** + * Deprecated, use @code db.client.connection.state @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.state @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kState = "state"; + +namespace StateValues +{ +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kUsed = "used"; + +} // namespace StateValues + +} // namespace other +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/peer_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/peer_attributes.h new file mode 100644 index 00000000000..6215d913f51 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/peer_attributes.h @@ -0,0 +1,31 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace peer +{ + +/** + * The @code service.name @endcode of the remote + * service. SHOULD be equal to the actual @code service.name @endcode resource attribute of the + * remote service if any. + */ +static constexpr const char *kPeerService = "peer.service"; + +} // namespace peer +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/pool_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/pool_attributes.h new file mode 100644 index 00000000000..6c26b22c239 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/pool_attributes.h @@ -0,0 +1,33 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace pool +{ + +/** + * Deprecated, use @code db.client.connection.pool.name @endcode instead. + *

        + * @deprecated + * Replaced by @code db.client.connection.pool.name @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kPoolName = "pool.name"; + +} // namespace pool +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h new file mode 100644 index 00000000000..de81b12c380 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h @@ -0,0 +1,264 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace process +{ + +/** + * Length of the process.command_args array + *

        + * This field can be useful for querying or performing bucket analysis on how many arguments were + * provided to start a process. More arguments may be an indication of suspicious activity. + */ +static constexpr const char *kProcessArgsCount = "process.args_count"; + +/** + * 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 @endcode. On Windows, can be set to the + * first parameter extracted from @code GetCommandLineW @endcode. + */ +static constexpr const char *kProcessCommand = "process.command"; + +/** + * 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 @endcode. For + * libc-based executables, this would be the full argv vector passed to @code main @endcode. + */ +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 @endcode. Do not set this if you have + * to assemble it just for monitoring; use @code process.command_args @endcode instead. + */ +static constexpr const char *kProcessCommandLine = "process.command_line"; + +/** + * Specifies whether the context switches for this data point were voluntary or involuntary. + */ +static constexpr const char *kProcessContextSwitchType = "process.context_switch_type"; + +/** + * Deprecated, use @code cpu.mode @endcode instead. + *

        + * @deprecated + * Replaced by @code cpu.mode @endcode + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kProcessCpuState = "process.cpu.state"; + +/** + * The date and time the process was created, in ISO 8601 format. + */ +static constexpr const char *kProcessCreationTime = "process.creation.time"; + +/** + * The GNU build ID as found in the @code .note.gnu.build-id @endcode ELF section (hex string). + */ +static constexpr const char *kProcessExecutableBuildIdGnu = "process.executable.build_id.gnu"; + +/** + * The Go build ID as retrieved by @code go tool buildid @endcode. + */ +static constexpr const char *kProcessExecutableBuildIdGo = "process.executable.build_id.go"; + +/** + * Profiling specific build ID for executables. See the OTel specification for Profiles for more + * information. + */ +static constexpr const char *kProcessExecutableBuildIdProfiling = + "process.executable.build_id.profiling"; + +/** + * The name of the process executable. On Linux based systems, can be set to the @code Name @endcode + * in @code proc/[pid]/status @endcode. On Windows, can be set to the base name of @code + * GetProcessImageFileNameW @endcode. + */ +static constexpr const char *kProcessExecutableName = "process.executable.name"; + +/** + * The full path to the process executable. On Linux based systems, can be set to the target of + * @code proc/[pid]/exe @endcode. On Windows, can be set to the result of @code + * GetProcessImageFileNameW @endcode. + */ +static constexpr const char *kProcessExecutablePath = "process.executable.path"; + +/** + * The exit code of the process. + */ +static constexpr const char *kProcessExitCode = "process.exit.code"; + +/** + * The date and time the process exited, in ISO 8601 format. + */ +static constexpr const char *kProcessExitTime = "process.exit.time"; + +/** + * The PID of the process's group leader. This is also the process group ID (PGID) of the process. + */ +static constexpr const char *kProcessGroupLeaderPid = "process.group_leader.pid"; + +/** + * Whether the process is connected to an interactive shell. + */ +static constexpr const char *kProcessInteractive = "process.interactive"; + +/** + * The username of the user that owns the process. + */ +static constexpr const char *kProcessOwner = "process.owner"; + +/** + * The type of page fault for this data point. Type @code major @endcode is for major/hard page + * faults, and @code minor @endcode is for minor/soft page faults. + */ +static constexpr const char *kProcessPagingFaultType = "process.paging.fault_type"; + +/** + * Parent Process identifier (PPID). + */ +static constexpr const char *kProcessParentPid = "process.parent_pid"; + +/** + * Process identifier (PID). + */ +static constexpr const char *kProcessPid = "process.pid"; + +/** + * The real user ID (RUID) of the process. + */ +static constexpr const char *kProcessRealUserId = "process.real_user.id"; + +/** + * The username of the real user of the process. + */ +static constexpr const char *kProcessRealUserName = "process.real_user.name"; + +/** + * 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"; + +/** + * The name of the runtime of this process. + */ +static constexpr const char *kProcessRuntimeName = "process.runtime.name"; + +/** + * The version of the runtime of this process, as returned by the runtime without modification. + */ +static constexpr const char *kProcessRuntimeVersion = "process.runtime.version"; + +/** + * The saved user ID (SUID) of the process. + */ +static constexpr const char *kProcessSavedUserId = "process.saved_user.id"; + +/** + * The username of the saved user. + */ +static constexpr const char *kProcessSavedUserName = "process.saved_user.name"; + +/** + * The PID of the process's session leader. This is also the session ID (SID) of the process. + */ +static constexpr const char *kProcessSessionLeaderPid = "process.session_leader.pid"; + +/** + * Process title (proctitle) + *

        + * In many Unix-like systems, process title (proctitle), is the string that represents the name or + * command line of a running process, displayed by system monitoring tools like ps, top, and htop. + */ +static constexpr const char *kProcessTitle = "process.title"; + +/** + * The effective user ID (EUID) of the process. + */ +static constexpr const char *kProcessUserId = "process.user.id"; + +/** + * The username of the effective user of the process. + */ +static constexpr const char *kProcessUserName = "process.user.name"; + +/** + * Virtual process identifier. + *

        + * The process ID within a PID namespace. This is not necessarily unique across all processes on the + * host but it is unique within the process namespace that the process exists within. + */ +static constexpr const char *kProcessVpid = "process.vpid"; + +/** + * The working directory of the process. + */ +static constexpr const char *kProcessWorkingDirectory = "process.working_directory"; + +namespace ProcessContextSwitchTypeValues +{ +/** + * none + */ +static constexpr const char *kVoluntary = "voluntary"; + +/** + * none + */ +static constexpr const char *kInvoluntary = "involuntary"; + +} // namespace ProcessContextSwitchTypeValues + +namespace ProcessCpuStateValues +{ +/** + * none + */ +static constexpr const char *kSystem = "system"; + +/** + * none + */ +static constexpr const char *kUser = "user"; + +/** + * none + */ +static constexpr const char *kWait = "wait"; + +} // namespace ProcessCpuStateValues + +namespace ProcessPagingFaultTypeValues +{ +/** + * none + */ +static constexpr const char *kMajor = "major"; + +/** + * none + */ +static constexpr const char *kMinor = "minor"; + +} // namespace ProcessPagingFaultTypeValues + +} // namespace process +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_metrics.h new file mode 100644 index 00000000000..5f851a2d411 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_metrics.h @@ -0,0 +1,454 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace process +{ + +/** + * Number of times the process has been context switched. + *

        + * counter + */ +static constexpr const char *kMetricProcessContextSwitches = "metric.process.context_switches"; +static constexpr const char *descrMetricProcessContextSwitches = + "Number of times the process has been context switched."; +static constexpr const char *unitMetricProcessContextSwitches = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessContextSwitches(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessContextSwitches, + descrMetricProcessContextSwitches, + unitMetricProcessContextSwitches); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessContextSwitches(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessContextSwitches, + descrMetricProcessContextSwitches, + unitMetricProcessContextSwitches); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessContextSwitches(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessContextSwitches, + descrMetricProcessContextSwitches, + unitMetricProcessContextSwitches); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessContextSwitches(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessContextSwitches, + descrMetricProcessContextSwitches, + unitMetricProcessContextSwitches); +} + +/** + * Total CPU seconds broken down by different states. + *

        + * counter + */ +static constexpr const char *kMetricProcessCpuTime = "metric.process.cpu.time"; +static constexpr const char *descrMetricProcessCpuTime = + "Total CPU seconds broken down by different states."; +static constexpr const char *unitMetricProcessCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessCpuTime, descrMetricProcessCpuTime, + unitMetricProcessCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessCpuTime, descrMetricProcessCpuTime, + unitMetricProcessCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricProcessCpuTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessCpuTime, descrMetricProcessCpuTime, + unitMetricProcessCpuTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessCpuTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessCpuTime, descrMetricProcessCpuTime, + unitMetricProcessCpuTime); +} + +/** + * Difference in process.cpu.time since the last measurement, divided by the elapsed time and number + * of CPUs available to the process.

        gauge + */ +static constexpr const char *kMetricProcessCpuUtilization = "metric.process.cpu.utilization"; +static constexpr const char *descrMetricProcessCpuUtilization = + "Difference in process.cpu.time since the last measurement, divided by the elapsed time and " + "number of CPUs available to the process."; +static constexpr const char *unitMetricProcessCpuUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessCpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricProcessCpuUtilization, descrMetricProcessCpuUtilization, + unitMetricProcessCpuUtilization); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessCpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricProcessCpuUtilization, descrMetricProcessCpuUtilization, + unitMetricProcessCpuUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessCpuUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricProcessCpuUtilization, + descrMetricProcessCpuUtilization, + unitMetricProcessCpuUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessCpuUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricProcessCpuUtilization, + descrMetricProcessCpuUtilization, + unitMetricProcessCpuUtilization); +} + +/** + * Disk bytes transferred. + *

        + * counter + */ +static constexpr const char *kMetricProcessDiskIo = "metric.process.disk.io"; +static constexpr const char *descrMetricProcessDiskIo = "Disk bytes transferred."; +static constexpr const char *unitMetricProcessDiskIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessDiskIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessDiskIo, descrMetricProcessDiskIo, + unitMetricProcessDiskIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessDiskIo, descrMetricProcessDiskIo, + unitMetricProcessDiskIo); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricProcessDiskIo( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessDiskIo, descrMetricProcessDiskIo, + unitMetricProcessDiskIo); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricProcessDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessDiskIo, descrMetricProcessDiskIo, + unitMetricProcessDiskIo); +} + +/** + * The amount of physical memory in use. + *

        + * updowncounter + */ +static constexpr const char *kMetricProcessMemoryUsage = "metric.process.memory.usage"; +static constexpr const char *descrMetricProcessMemoryUsage = + "The amount of physical memory in use."; +static constexpr const char *unitMetricProcessMemoryUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricProcessMemoryUsage, descrMetricProcessMemoryUsage, + unitMetricProcessMemoryUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricProcessMemoryUsage, descrMetricProcessMemoryUsage, + unitMetricProcessMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricProcessMemoryUsage, descrMetricProcessMemoryUsage, unitMetricProcessMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricProcessMemoryUsage, descrMetricProcessMemoryUsage, unitMetricProcessMemoryUsage); +} + +/** + * The amount of committed virtual memory. + *

        + * updowncounter + */ +static constexpr const char *kMetricProcessMemoryVirtual = "metric.process.memory.virtual"; +static constexpr const char *descrMetricProcessMemoryVirtual = + "The amount of committed virtual memory."; +static constexpr const char *unitMetricProcessMemoryVirtual = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessMemoryVirtual(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter( + kMetricProcessMemoryVirtual, descrMetricProcessMemoryVirtual, unitMetricProcessMemoryVirtual); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessMemoryVirtual(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter( + kMetricProcessMemoryVirtual, descrMetricProcessMemoryVirtual, unitMetricProcessMemoryVirtual); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessMemoryVirtual(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricProcessMemoryVirtual, descrMetricProcessMemoryVirtual, unitMetricProcessMemoryVirtual); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessMemoryVirtual(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricProcessMemoryVirtual, descrMetricProcessMemoryVirtual, unitMetricProcessMemoryVirtual); +} + +/** + * Network bytes transferred. + *

        + * counter + */ +static constexpr const char *kMetricProcessNetworkIo = "metric.process.network.io"; +static constexpr const char *descrMetricProcessNetworkIo = "Network bytes transferred."; +static constexpr const char *unitMetricProcessNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessNetworkIo, descrMetricProcessNetworkIo, + unitMetricProcessNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessNetworkIo, descrMetricProcessNetworkIo, + unitMetricProcessNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessNetworkIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessNetworkIo, descrMetricProcessNetworkIo, + unitMetricProcessNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessNetworkIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessNetworkIo, descrMetricProcessNetworkIo, + unitMetricProcessNetworkIo); +} + +/** + * Number of file descriptors in use by the process. + *

        + * updowncounter + */ +static constexpr const char *kMetricProcessOpenFileDescriptorCount = + "metric.process.open_file_descriptor.count"; +static constexpr const char *descrMetricProcessOpenFileDescriptorCount = + "Number of file descriptors in use by the process."; +static constexpr const char *unitMetricProcessOpenFileDescriptorCount = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessOpenFileDescriptorCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricProcessOpenFileDescriptorCount, + descrMetricProcessOpenFileDescriptorCount, + unitMetricProcessOpenFileDescriptorCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessOpenFileDescriptorCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricProcessOpenFileDescriptorCount, + descrMetricProcessOpenFileDescriptorCount, + unitMetricProcessOpenFileDescriptorCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessOpenFileDescriptorCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricProcessOpenFileDescriptorCount, + descrMetricProcessOpenFileDescriptorCount, + unitMetricProcessOpenFileDescriptorCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessOpenFileDescriptorCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricProcessOpenFileDescriptorCount, + descrMetricProcessOpenFileDescriptorCount, + unitMetricProcessOpenFileDescriptorCount); +} + +/** + * Number of page faults the process has made. + *

        + * counter + */ +static constexpr const char *kMetricProcessPagingFaults = "metric.process.paging.faults"; +static constexpr const char *descrMetricProcessPagingFaults = + "Number of page faults the process has made."; +static constexpr const char *unitMetricProcessPagingFaults = "{fault}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessPagingFaults(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessPagingFaults, descrMetricProcessPagingFaults, + unitMetricProcessPagingFaults); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessPagingFaults( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessPagingFaults, descrMetricProcessPagingFaults, + unitMetricProcessPagingFaults); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessPagingFaults(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricProcessPagingFaults, descrMetricProcessPagingFaults, unitMetricProcessPagingFaults); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessPagingFaults(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricProcessPagingFaults, descrMetricProcessPagingFaults, unitMetricProcessPagingFaults); +} + +/** + * Process threads count. + *

        + * updowncounter + */ +static constexpr const char *kMetricProcessThreadCount = "metric.process.thread.count"; +static constexpr const char *descrMetricProcessThreadCount = "Process threads count."; +static constexpr const char *unitMetricProcessThreadCount = "{thread}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricProcessThreadCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricProcessThreadCount, descrMetricProcessThreadCount, + unitMetricProcessThreadCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricProcessThreadCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricProcessThreadCount, descrMetricProcessThreadCount, + unitMetricProcessThreadCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricProcessThreadCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricProcessThreadCount, descrMetricProcessThreadCount, unitMetricProcessThreadCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricProcessThreadCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricProcessThreadCount, descrMetricProcessThreadCount, unitMetricProcessThreadCount); +} + +/** + * The time the process has been running. + *

        + * Instrumentations SHOULD use counter with type @code double @endcode and measure uptime with at + * least millisecond precision

        counter + */ +static constexpr const char *kMetricProcessUptime = "metric.process.uptime"; +static constexpr const char *descrMetricProcessUptime = "The time the process has been running."; +static constexpr const char *unitMetricProcessUptime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricProcessUptime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricProcessUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricProcessUptime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricProcessUptime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricProcessUptime, descrMetricProcessUptime, + unitMetricProcessUptime); +} + +} // namespace process +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/profile_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/profile_attributes.h new file mode 100644 index 00000000000..076177904ff --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/profile_attributes.h @@ -0,0 +1,81 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace profile +{ + +/** + * Describes the interpreter or compiler of a single frame. + */ +static constexpr const char *kProfileFrameType = "profile.frame.type"; + +namespace ProfileFrameTypeValues +{ +/** + * .NET + */ +static constexpr const char *kDotnet = "dotnet"; + +/** + * JVM + */ +static constexpr const char *kJvm = "jvm"; + +/** + * Kernel + */ +static constexpr const char *kKernel = "kernel"; + +/** + * C, C++, Go, Rust + */ +static constexpr const char *kNative = "native"; + +/** + * Perl + */ +static constexpr const char *kPerl = "perl"; + +/** + * PHP + */ +static constexpr const char *kPhp = "php"; + +/** + * Python + */ +static constexpr const char *kCpython = "cpython"; + +/** + * Ruby + */ +static constexpr const char *kRuby = "ruby"; + +/** + * V8JS + */ +static constexpr const char *kV8js = "v8js"; + +} // namespace ProfileFrameTypeValues + +} // namespace profile +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_attributes.h new file mode 100644 index 00000000000..49ba418512a --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_attributes.h @@ -0,0 +1,355 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace rpc +{ + +/** + * The error codes of the Connect + * request. Error codes are always string values. + */ +static constexpr const char *kRpcConnectRpcErrorCode = "rpc.connect_rpc.error_code"; + +/** + * Connect request metadata, @code @endcode being the normalized Connect Metadata key + * (lowercase), the value being the metadata values.

        Instrumentations SHOULD require an explicit + * configuration of which metadata values are to be captured. Including all request metadata values + * can be a security risk - explicit configuration helps avoid leaking sensitive information. + */ +static constexpr const char *kRpcConnectRpcRequestMetadata = "rpc.connect_rpc.request.metadata"; + +/** + * Connect response metadata, @code @endcode being the normalized Connect Metadata key + * (lowercase), the value being the metadata values.

        Instrumentations SHOULD require an explicit + * configuration of which metadata values are to be captured. Including all response metadata values + * can be a security risk - explicit configuration helps avoid leaking sensitive information. + */ +static constexpr const char *kRpcConnectRpcResponseMetadata = "rpc.connect_rpc.response.metadata"; + +/** + * gRPC request metadata, @code @endcode being the normalized gRPC Metadata key (lowercase), + * the value being the metadata values.

        Instrumentations SHOULD require an explicit + * configuration of which metadata values are to be captured. Including all request metadata values + * can be a security risk - explicit configuration helps avoid leaking sensitive information. + */ +static constexpr const char *kRpcGrpcRequestMetadata = "rpc.grpc.request.metadata"; + +/** + * gRPC response metadata, @code @endcode being the normalized gRPC Metadata key (lowercase), + * the value being the metadata values.

        Instrumentations SHOULD require an explicit + * configuration of which metadata values are to be captured. Including all response metadata values + * can be a security risk - explicit configuration helps avoid leaking sensitive information. + */ +static constexpr const char *kRpcGrpcResponseMetadata = "rpc.grpc.response.metadata"; + +/** + * The numeric status + * code of the gRPC request. + */ +static constexpr const char *kRpcGrpcStatusCode = "rpc.grpc.status_code"; + +/** + * @code error.code @endcode property of response if it is an error response. + */ +static constexpr const char *kRpcJsonrpcErrorCode = "rpc.jsonrpc.error_code"; + +/** + * @code error.message @endcode property of response if it is an error response. + */ +static constexpr const char *kRpcJsonrpcErrorMessage = "rpc.jsonrpc.error_message"; + +/** + * @code id @endcode property of request or response. Since protocol allows id to be int, string, + * @code null @endcode or missing (for notifications), value is expected to be cast to string for + * simplicity. Use empty string in case of @code null @endcode value. Omit entirely if this is a + * notification. + */ +static constexpr const char *kRpcJsonrpcRequestId = "rpc.jsonrpc.request_id"; + +/** + * Protocol version as in @code jsonrpc @endcode property of request/response. Since JSON-RPC 1.0 + * doesn't specify this, the value can be omitted. + */ +static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; + +/** + * Compressed size of the message in bytes. + */ +static constexpr const char *kRpcMessageCompressedSize = "rpc.message.compressed_size"; + +/** + * MUST be calculated as two different counters starting from @code 1 @endcode one for sent messages + * and one for received message.

        This way we guarantee that the values will be consistent + * between different implementations. + */ +static constexpr const char *kRpcMessageId = "rpc.message.id"; + +/** + * Whether this is a received or sent message. + */ +static constexpr const char *kRpcMessageType = "rpc.message.type"; + +/** + * Uncompressed size of the message in bytes. + */ +static constexpr const char *kRpcMessageUncompressedSize = "rpc.message.uncompressed_size"; + +/** + * The name of the (logical) method being called, must be equal to the $method part in the span + * name.

        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 @endcode + * 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 *kRpcMethod = "rpc.method"; + +/** + * The full (logical) name of the service being called, including its package name, if applicable. + *

        + * This is the logical name of the service from the RPC interface perspective, which can be + * different from the name of any implementing class. The @code code.namespace @endcode attribute + * may be used to store the latter (despite the attribute name, it may include a class name; e.g., + * class with method actually executing the call on the server side, RPC client stub class on the + * client side). + */ +static constexpr const char *kRpcService = "rpc.service"; + +/** + * A string identifying the remoting system. See below for a list of well-known identifiers. + */ +static constexpr const char *kRpcSystem = "rpc.system"; + +namespace RpcConnectRpcErrorCodeValues +{ +/** + * none + */ +static constexpr const char *kCancelled = "cancelled"; + +/** + * none + */ +static constexpr const char *kUnknown = "unknown"; + +/** + * none + */ +static constexpr const char *kInvalidArgument = "invalid_argument"; + +/** + * none + */ +static constexpr const char *kDeadlineExceeded = "deadline_exceeded"; + +/** + * none + */ +static constexpr const char *kNotFound = "not_found"; + +/** + * none + */ +static constexpr const char *kAlreadyExists = "already_exists"; + +/** + * none + */ +static constexpr const char *kPermissionDenied = "permission_denied"; + +/** + * none + */ +static constexpr const char *kResourceExhausted = "resource_exhausted"; + +/** + * none + */ +static constexpr const char *kFailedPrecondition = "failed_precondition"; + +/** + * none + */ +static constexpr const char *kAborted = "aborted"; + +/** + * none + */ +static constexpr const char *kOutOfRange = "out_of_range"; + +/** + * none + */ +static constexpr const char *kUnimplemented = "unimplemented"; + +/** + * none + */ +static constexpr const char *kInternal = "internal"; + +/** + * none + */ +static constexpr const char *kUnavailable = "unavailable"; + +/** + * none + */ +static constexpr const char *kDataLoss = "data_loss"; + +/** + * none + */ +static constexpr const char *kUnauthenticated = "unauthenticated"; + +} // namespace RpcConnectRpcErrorCodeValues + +namespace RpcGrpcStatusCodeValues +{ +/** + * OK + */ +static constexpr int kOk = 0; + +/** + * CANCELLED + */ +static constexpr int kCancelled = 1; + +/** + * UNKNOWN + */ +static constexpr int kUnknown = 2; + +/** + * INVALID_ARGUMENT + */ +static constexpr int kInvalidArgument = 3; + +/** + * DEADLINE_EXCEEDED + */ +static constexpr int kDeadlineExceeded = 4; + +/** + * NOT_FOUND + */ +static constexpr int kNotFound = 5; + +/** + * ALREADY_EXISTS + */ +static constexpr int kAlreadyExists = 6; + +/** + * PERMISSION_DENIED + */ +static constexpr int kPermissionDenied = 7; + +/** + * RESOURCE_EXHAUSTED + */ +static constexpr int kResourceExhausted = 8; + +/** + * FAILED_PRECONDITION + */ +static constexpr int kFailedPrecondition = 9; + +/** + * ABORTED + */ +static constexpr int kAborted = 10; + +/** + * OUT_OF_RANGE + */ +static constexpr int kOutOfRange = 11; + +/** + * UNIMPLEMENTED + */ +static constexpr int kUnimplemented = 12; + +/** + * INTERNAL + */ +static constexpr int kInternal = 13; + +/** + * UNAVAILABLE + */ +static constexpr int kUnavailable = 14; + +/** + * DATA_LOSS + */ +static constexpr int kDataLoss = 15; + +/** + * UNAUTHENTICATED + */ +static constexpr int kUnauthenticated = 16; + +} // namespace RpcGrpcStatusCodeValues + +namespace RpcMessageTypeValues +{ +/** + * none + */ +static constexpr const char *kSent = "SENT"; + +/** + * none + */ +static constexpr const char *kReceived = "RECEIVED"; + +} // namespace RpcMessageTypeValues + +namespace RpcSystemValues +{ +/** + * gRPC + */ +static constexpr const char *kGrpc = "grpc"; + +/** + * Java RMI + */ +static constexpr const char *kJavaRmi = "java_rmi"; + +/** + * .NET WCF + */ +static constexpr const char *kDotnetWcf = "dotnet_wcf"; + +/** + * Apache Dubbo + */ +static constexpr const char *kApacheDubbo = "apache_dubbo"; + +/** + * Connect RPC + */ +static constexpr const char *kConnectRpc = "connect_rpc"; + +} // namespace RpcSystemValues + +} // namespace rpc +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_metrics.h new file mode 100644 index 00000000000..30e95ce7108 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_metrics.h @@ -0,0 +1,312 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace rpc +{ + +/** + * Measures the duration of outbound RPC. + *

        + * While streaming RPCs may record this metric as start-of-batch + * to end-of-batch, it's hard to interpret in practice. + *

        + * Streaming: N/A. + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientDuration = "metric.rpc.client.duration"; +static constexpr const char *descrMetricRpcClientDuration = + "Measures the duration of outbound RPC."; +static constexpr const char *unitMetricRpcClientDuration = "ms"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientDuration, descrMetricRpcClientDuration, + unitMetricRpcClientDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricRpcClientDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientDuration, descrMetricRpcClientDuration, + unitMetricRpcClientDuration); +} + +/** + * Measures the size of RPC request messages (uncompressed). + *

        + * Streaming: Recorded per message in a streaming batch + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientRequestSize = "metric.rpc.client.request.size"; +static constexpr const char *descrMetricRpcClientRequestSize = + "Measures the size of RPC request messages (uncompressed)."; +static constexpr const char *unitMetricRpcClientRequestSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientRequestSize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientRequestSize, descrMetricRpcClientRequestSize, + unitMetricRpcClientRequestSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcClientRequestSize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientRequestSize, descrMetricRpcClientRequestSize, + unitMetricRpcClientRequestSize); +} + +/** + * Measures the number of messages received per RPC. + *

        + * Should be 1 for all non-streaming RPCs. + *

        + * Streaming: This metric is required for server and client streaming RPCs + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientRequestsPerRpc = "metric.rpc.client.requests_per_rpc"; +static constexpr const char *descrMetricRpcClientRequestsPerRpc = + "Measures the number of messages received per RPC."; +static constexpr const char *unitMetricRpcClientRequestsPerRpc = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientRequestsPerRpc(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientRequestsPerRpc, + descrMetricRpcClientRequestsPerRpc, + unitMetricRpcClientRequestsPerRpc); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcClientRequestsPerRpc(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientRequestsPerRpc, + descrMetricRpcClientRequestsPerRpc, + unitMetricRpcClientRequestsPerRpc); +} + +/** + * Measures the size of RPC response messages (uncompressed). + *

        + * Streaming: Recorded per response in a streaming batch + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientResponseSize = "metric.rpc.client.response.size"; +static constexpr const char *descrMetricRpcClientResponseSize = + "Measures the size of RPC response messages (uncompressed)."; +static constexpr const char *unitMetricRpcClientResponseSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientResponseSize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientResponseSize, + descrMetricRpcClientResponseSize, + unitMetricRpcClientResponseSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcClientResponseSize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientResponseSize, + descrMetricRpcClientResponseSize, + unitMetricRpcClientResponseSize); +} + +/** + * Measures the number of messages sent per RPC. + *

        + * Should be 1 for all non-streaming RPCs. + *

        + * Streaming: This metric is required for server and client streaming RPCs + *

        + * histogram + */ +static constexpr const char *kMetricRpcClientResponsesPerRpc = + "metric.rpc.client.responses_per_rpc"; +static constexpr const char *descrMetricRpcClientResponsesPerRpc = + "Measures the number of messages sent per RPC."; +static constexpr const char *unitMetricRpcClientResponsesPerRpc = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcClientResponsesPerRpc(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcClientResponsesPerRpc, + descrMetricRpcClientResponsesPerRpc, + unitMetricRpcClientResponsesPerRpc); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcClientResponsesPerRpc(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcClientResponsesPerRpc, + descrMetricRpcClientResponsesPerRpc, + unitMetricRpcClientResponsesPerRpc); +} + +/** + * Measures the duration of inbound RPC. + *

        + * While streaming RPCs may record this metric as start-of-batch + * to end-of-batch, it's hard to interpret in practice. + *

        + * Streaming: N/A. + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerDuration = "metric.rpc.server.duration"; +static constexpr const char *descrMetricRpcServerDuration = "Measures the duration of inbound RPC."; +static constexpr const char *unitMetricRpcServerDuration = "ms"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerDuration(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerDuration, descrMetricRpcServerDuration, + unitMetricRpcServerDuration); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricRpcServerDuration( + metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerDuration, descrMetricRpcServerDuration, + unitMetricRpcServerDuration); +} + +/** + * Measures the size of RPC request messages (uncompressed). + *

        + * Streaming: Recorded per message in a streaming batch + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerRequestSize = "metric.rpc.server.request.size"; +static constexpr const char *descrMetricRpcServerRequestSize = + "Measures the size of RPC request messages (uncompressed)."; +static constexpr const char *unitMetricRpcServerRequestSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerRequestSize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerRequestSize, descrMetricRpcServerRequestSize, + unitMetricRpcServerRequestSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcServerRequestSize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerRequestSize, descrMetricRpcServerRequestSize, + unitMetricRpcServerRequestSize); +} + +/** + * Measures the number of messages received per RPC. + *

        + * Should be 1 for all non-streaming RPCs. + *

        + * Streaming : This metric is required for server and client streaming RPCs + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerRequestsPerRpc = "metric.rpc.server.requests_per_rpc"; +static constexpr const char *descrMetricRpcServerRequestsPerRpc = + "Measures the number of messages received per RPC."; +static constexpr const char *unitMetricRpcServerRequestsPerRpc = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerRequestsPerRpc(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerRequestsPerRpc, + descrMetricRpcServerRequestsPerRpc, + unitMetricRpcServerRequestsPerRpc); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcServerRequestsPerRpc(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerRequestsPerRpc, + descrMetricRpcServerRequestsPerRpc, + unitMetricRpcServerRequestsPerRpc); +} + +/** + * Measures the size of RPC response messages (uncompressed). + *

        + * Streaming: Recorded per response in a streaming batch + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerResponseSize = "metric.rpc.server.response.size"; +static constexpr const char *descrMetricRpcServerResponseSize = + "Measures the size of RPC response messages (uncompressed)."; +static constexpr const char *unitMetricRpcServerResponseSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerResponseSize(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerResponseSize, + descrMetricRpcServerResponseSize, + unitMetricRpcServerResponseSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcServerResponseSize(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerResponseSize, + descrMetricRpcServerResponseSize, + unitMetricRpcServerResponseSize); +} + +/** + * Measures the number of messages sent per RPC. + *

        + * Should be 1 for all non-streaming RPCs. + *

        + * Streaming: This metric is required for server and client streaming RPCs + *

        + * histogram + */ +static constexpr const char *kMetricRpcServerResponsesPerRpc = + "metric.rpc.server.responses_per_rpc"; +static constexpr const char *descrMetricRpcServerResponsesPerRpc = + "Measures the number of messages sent per RPC."; +static constexpr const char *unitMetricRpcServerResponsesPerRpc = "{count}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricRpcServerResponsesPerRpc(metrics::Meter *meter) +{ + return meter->CreateUInt64Histogram(kMetricRpcServerResponsesPerRpc, + descrMetricRpcServerResponsesPerRpc, + unitMetricRpcServerResponsesPerRpc); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricRpcServerResponsesPerRpc(metrics::Meter *meter) +{ + return meter->CreateDoubleHistogram(kMetricRpcServerResponsesPerRpc, + descrMetricRpcServerResponsesPerRpc, + unitMetricRpcServerResponsesPerRpc); +} + +} // namespace rpc +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/server_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/server_attributes.h new file mode 100644 index 00000000000..21cb75d729a --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/server_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace server +{ + +/** + * Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain + * socket name.

        When observed from the client side, and when communicating through an + * intermediary, @code server.address @endcode SHOULD represent the server address behind any + * intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kServerAddress = "server.address"; + +/** + * Server port number. + *

        + * When observed from the client side, and when communicating through an intermediary, @code + * server.port @endcode SHOULD represent the server port behind any intermediaries, for example + * proxies, if it's available. + */ +static constexpr const char *kServerPort = "server.port"; + +} // namespace server +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/service_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/service_attributes.h new file mode 100644 index 00000000000..7582c19868f --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/service_attributes.h @@ -0,0 +1,84 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace service +{ + +/** + * The string ID of the service instance. + *

        + * MUST be unique for each instance of the same @code service.namespace,service.name @endcode pair + * (in other words + * @code service.namespace,service.name,service.instance.id @endcode triplet MUST be globally + * unique). The ID helps to distinguish instances of the same service that exist at the same time + * (e.g. instances of a horizontally scaled service).

        Implementations, such as SDKs, are + * recommended to generate a random Version 1 or Version 4 RFC 4122 UUID, but are free to use an inherent + * unique ID as the source of this value if stability is desirable. In that case, the ID SHOULD be + * used as source of a UUID Version 5 and SHOULD use the following UUID as the namespace: @code + * 4d63009a-8d0f-11ee-aad7-4c796ed8e320 @endcode.

        UUIDs are typically recommended, as only an + * opaque value for the purposes of identifying a service instance is needed. Similar to what can be + * seen in the man page for the @code /etc/machine-id + * @endcode file, the underlying data, such as pod name and namespace should be treated as + * confidential, being the user's choice to expose it or not via another resource attribute.

        For + * applications running behind an application server (like unicorn), we do not recommend using one + * identifier for all processes participating in the application. Instead, it's recommended each + * division (e.g. a worker thread in unicorn) to have its own instance.id.

        It's not recommended + * for a Collector to set @code service.instance.id @endcode if it can't unambiguously determine the + * service instance that is generating that telemetry. For instance, creating an UUID based on @code + * pod.name @endcode will likely be wrong, as the Collector might not know from which container + * within that pod the telemetry originated. However, Collectors can set the @code + * service.instance.id @endcode if they can unambiguously determine the service instance for that + * telemetry. This is typically the case for scraping receivers, as they know the target address and + * port. + */ +static constexpr const char *kServiceInstanceId = "service.instance.id"; + +/** + * Logical name of the service. + *

        + * MUST be the same for all instances of horizontally scaled services. If the value was not + * specified, SDKs MUST fallback to @code unknown_service: @endcode concatenated with @code process.executable.name @endcode, e.g. @code unknown_service:bash + * @endcode. If @code process.executable.name @endcode is not available, the value MUST be set to + * @code unknown_service @endcode. + */ +static constexpr const char *kServiceName = "service.name"; + +/** + * A namespace for @code service.name @endcode. + *

        + * 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 @endcode is expected to be unique + * within the same namespace. If @code service.namespace @endcode is not specified in the Resource + * then @code service.name @endcode 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 version string of the service API or implementation. The format is not defined by these + * conventions. + */ +static constexpr const char *kServiceVersion = "service.version"; + +} // namespace service +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/session_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/session_attributes.h new file mode 100644 index 00000000000..abbe9446d64 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/session_attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace session +{ + +/** + * A unique id to identify a session. + */ +static constexpr const char *kSessionId = "session.id"; + +/** + * The previous @code session.id @endcode for this user, when known. + */ +static constexpr const char *kSessionPreviousId = "session.previous_id"; + +} // namespace session +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/source_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/source_attributes.h new file mode 100644 index 00000000000..06a6ddc2f62 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/source_attributes.h @@ -0,0 +1,37 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace source +{ + +/** + * Source address - domain name if available without reverse DNS lookup; otherwise, IP address or + * Unix domain socket name.

        When observed from the destination side, and when communicating + * through an intermediary, @code source.address @endcode SHOULD represent the source address behind + * any intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kSourceAddress = "source.address"; + +/** + * Source port number + */ +static constexpr const char *kSourcePort = "source.port"; + +} // namespace source +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_attributes.h new file mode 100644 index 00000000000..be7ec801864 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_attributes.h @@ -0,0 +1,383 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace system +{ + +/** + * The logical CPU number [0..n-1] + */ +static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; + +/** + * Deprecated, use @code cpu.mode @endcode instead. + *

        + * @deprecated + * Replaced by @code cpu.mode @endcode + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kSystemCpuState = "system.cpu.state"; + +/** + * The device identifier + */ +static constexpr const char *kSystemDevice = "system.device"; + +/** + * The filesystem mode + */ +static constexpr const char *kSystemFilesystemMode = "system.filesystem.mode"; + +/** + * The filesystem mount path + */ +static constexpr const char *kSystemFilesystemMountpoint = "system.filesystem.mountpoint"; + +/** + * The filesystem state + */ +static constexpr const char *kSystemFilesystemState = "system.filesystem.state"; + +/** + * The filesystem type + */ +static constexpr const char *kSystemFilesystemType = "system.filesystem.type"; + +/** + * The memory state + */ +static constexpr const char *kSystemMemoryState = "system.memory.state"; + +/** + * A stateless protocol MUST NOT set this attribute + */ +static constexpr const char *kSystemNetworkState = "system.network.state"; + +/** + * The paging access direction + */ +static constexpr const char *kSystemPagingDirection = "system.paging.direction"; + +/** + * The memory paging state + */ +static constexpr const char *kSystemPagingState = "system.paging.state"; + +/** + * The memory paging type + */ +static constexpr const char *kSystemPagingType = "system.paging.type"; + +/** + * The process state, e.g., Linux Process State + * Codes + */ +static constexpr const char *kSystemProcessStatus = "system.process.status"; + +/** + * Deprecated, use @code system.process.status @endcode instead. + *

        + * @deprecated + * Replaced by @code system.process.status @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kSystemProcessesStatus = "system.processes.status"; + +namespace SystemCpuStateValues +{ +/** + * none + */ +static constexpr const char *kUser = "user"; + +/** + * none + */ +static constexpr const char *kSystem = "system"; + +/** + * none + */ +static constexpr const char *kNice = "nice"; + +/** + * none + */ +static constexpr const char *kIdle = "idle"; + +/** + * none + */ +static constexpr const char *kIowait = "iowait"; + +/** + * none + */ +static constexpr const char *kInterrupt = "interrupt"; + +/** + * none + */ +static constexpr const char *kSteal = "steal"; + +} // namespace SystemCpuStateValues + +namespace SystemFilesystemStateValues +{ +/** + * none + */ +static constexpr const char *kUsed = "used"; + +/** + * none + */ +static constexpr const char *kFree = "free"; + +/** + * none + */ +static constexpr const char *kReserved = "reserved"; + +} // namespace SystemFilesystemStateValues + +namespace SystemFilesystemTypeValues +{ +/** + * none + */ +static constexpr const char *kFat32 = "fat32"; + +/** + * none + */ +static constexpr const char *kExfat = "exfat"; + +/** + * none + */ +static constexpr const char *kNtfs = "ntfs"; + +/** + * none + */ +static constexpr const char *kRefs = "refs"; + +/** + * none + */ +static constexpr const char *kHfsplus = "hfsplus"; + +/** + * none + */ +static constexpr const char *kExt4 = "ext4"; + +} // namespace SystemFilesystemTypeValues + +namespace SystemMemoryStateValues +{ +/** + * none + */ +static constexpr const char *kUsed = "used"; + +/** + * none + */ +static constexpr const char *kFree = "free"; + +/** + * none + *

        + * @deprecated + * Removed, report shared memory usage with @code metric.system.memory.shared @endcode metric + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kShared = "shared"; + +/** + * none + */ +static constexpr const char *kBuffers = "buffers"; + +/** + * none + */ +static constexpr const char *kCached = "cached"; + +} // namespace SystemMemoryStateValues + +namespace SystemNetworkStateValues +{ +/** + * none + */ +static constexpr const char *kClose = "close"; + +/** + * none + */ +static constexpr const char *kCloseWait = "close_wait"; + +/** + * none + */ +static constexpr const char *kClosing = "closing"; + +/** + * none + */ +static constexpr const char *kDelete = "delete"; + +/** + * none + */ +static constexpr const char *kEstablished = "established"; + +/** + * none + */ +static constexpr const char *kFinWait1 = "fin_wait_1"; + +/** + * none + */ +static constexpr const char *kFinWait2 = "fin_wait_2"; + +/** + * none + */ +static constexpr const char *kLastAck = "last_ack"; + +/** + * none + */ +static constexpr const char *kListen = "listen"; + +/** + * none + */ +static constexpr const char *kSynRecv = "syn_recv"; + +/** + * none + */ +static constexpr const char *kSynSent = "syn_sent"; + +/** + * none + */ +static constexpr const char *kTimeWait = "time_wait"; + +} // namespace SystemNetworkStateValues + +namespace SystemPagingDirectionValues +{ +/** + * none + */ +static constexpr const char *kIn = "in"; + +/** + * none + */ +static constexpr const char *kOut = "out"; + +} // namespace SystemPagingDirectionValues + +namespace SystemPagingStateValues +{ +/** + * none + */ +static constexpr const char *kUsed = "used"; + +/** + * none + */ +static constexpr const char *kFree = "free"; + +} // namespace SystemPagingStateValues + +namespace SystemPagingTypeValues +{ +/** + * none + */ +static constexpr const char *kMajor = "major"; + +/** + * none + */ +static constexpr const char *kMinor = "minor"; + +} // namespace SystemPagingTypeValues + +namespace SystemProcessStatusValues +{ +/** + * none + */ +static constexpr const char *kRunning = "running"; + +/** + * none + */ +static constexpr const char *kSleeping = "sleeping"; + +/** + * none + */ +static constexpr const char *kStopped = "stopped"; + +/** + * none + */ +static constexpr const char *kDefunct = "defunct"; + +} // namespace SystemProcessStatusValues + +namespace SystemProcessesStatusValues +{ +/** + * none + */ +static constexpr const char *kRunning = "running"; + +/** + * none + */ +static constexpr const char *kSleeping = "sleeping"; + +/** + * none + */ +static constexpr const char *kStopped = "stopped"; + +/** + * none + */ +static constexpr const char *kDefunct = "defunct"; + +} // namespace SystemProcessesStatusValues + +} // namespace system +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_metrics.h new file mode 100644 index 00000000000..a23a8ae4d08 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_metrics.h @@ -0,0 +1,1284 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace system +{ + +/** + * Reports the current frequency of the CPU in Hz + *

        + * gauge + */ +static constexpr const char *kMetricSystemCpuFrequency = "metric.system.cpu.frequency"; +static constexpr const char *descrMetricSystemCpuFrequency = + "Reports the current frequency of the CPU in Hz"; +static constexpr const char *unitMetricSystemCpuFrequency = "{Hz}"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemCpuFrequency( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemCpuFrequency, descrMetricSystemCpuFrequency, + unitMetricSystemCpuFrequency); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemCpuFrequency( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemCpuFrequency, descrMetricSystemCpuFrequency, + unitMetricSystemCpuFrequency); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemCpuFrequency(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemCpuFrequency, descrMetricSystemCpuFrequency, + unitMetricSystemCpuFrequency); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemCpuFrequency(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricSystemCpuFrequency, descrMetricSystemCpuFrequency, unitMetricSystemCpuFrequency); +} + +/** + * Reports the number of logical (virtual) processor cores created by the operating system to manage + * multitasking

        updowncounter + */ +static constexpr const char *kMetricSystemCpuLogicalCount = "metric.system.cpu.logical.count"; +static constexpr const char *descrMetricSystemCpuLogicalCount = + "Reports the number of logical (virtual) processor cores created by the operating system to " + "manage multitasking"; +static constexpr const char *unitMetricSystemCpuLogicalCount = "{cpu}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemCpuLogicalCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemCpuLogicalCount, + descrMetricSystemCpuLogicalCount, + unitMetricSystemCpuLogicalCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemCpuLogicalCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemCpuLogicalCount, + descrMetricSystemCpuLogicalCount, + unitMetricSystemCpuLogicalCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemCpuLogicalCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemCpuLogicalCount, + descrMetricSystemCpuLogicalCount, + unitMetricSystemCpuLogicalCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemCpuLogicalCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemCpuLogicalCount, + descrMetricSystemCpuLogicalCount, + unitMetricSystemCpuLogicalCount); +} + +/** + * Reports the number of actual physical processor cores on the hardware + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemCpuPhysicalCount = "metric.system.cpu.physical.count"; +static constexpr const char *descrMetricSystemCpuPhysicalCount = + "Reports the number of actual physical processor cores on the hardware"; +static constexpr const char *unitMetricSystemCpuPhysicalCount = "{cpu}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemCpuPhysicalCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemCpuPhysicalCount, + descrMetricSystemCpuPhysicalCount, + unitMetricSystemCpuPhysicalCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemCpuPhysicalCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemCpuPhysicalCount, + descrMetricSystemCpuPhysicalCount, + unitMetricSystemCpuPhysicalCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemCpuPhysicalCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemCpuPhysicalCount, + descrMetricSystemCpuPhysicalCount, + unitMetricSystemCpuPhysicalCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemCpuPhysicalCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemCpuPhysicalCount, + descrMetricSystemCpuPhysicalCount, + unitMetricSystemCpuPhysicalCount); +} + +/** + * Seconds each logical CPU spent on each mode + *

        + * counter + */ +static constexpr const char *kMetricSystemCpuTime = "metric.system.cpu.time"; +static constexpr const char *descrMetricSystemCpuTime = + "Seconds each logical CPU spent on each mode"; +static constexpr const char *unitMetricSystemCpuTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemCpuTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemCpuTime, descrMetricSystemCpuTime, + unitMetricSystemCpuTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemCpuTime, descrMetricSystemCpuTime, + unitMetricSystemCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricSystemCpuTime( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemCpuTime, descrMetricSystemCpuTime, + unitMetricSystemCpuTime); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricSystemCpuTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemCpuTime, descrMetricSystemCpuTime, + unitMetricSystemCpuTime); +} + +/** + * Difference in system.cpu.time since the last measurement, divided by the elapsed time and number + * of logical CPUs

        gauge + */ +static constexpr const char *kMetricSystemCpuUtilization = "metric.system.cpu.utilization"; +static constexpr const char *descrMetricSystemCpuUtilization = + "Difference in system.cpu.time since the last measurement, divided by the elapsed time and " + "number of logical CPUs"; +static constexpr const char *unitMetricSystemCpuUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemCpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemCpuUtilization, descrMetricSystemCpuUtilization, + unitMetricSystemCpuUtilization); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemCpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemCpuUtilization, descrMetricSystemCpuUtilization, + unitMetricSystemCpuUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemCpuUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge( + kMetricSystemCpuUtilization, descrMetricSystemCpuUtilization, unitMetricSystemCpuUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemCpuUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricSystemCpuUtilization, descrMetricSystemCpuUtilization, unitMetricSystemCpuUtilization); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemDiskIo = "metric.system.disk.io"; +static constexpr const char *descrMetricSystemDiskIo = ""; +static constexpr const char *unitMetricSystemDiskIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskIo, descrMetricSystemDiskIo, + unitMetricSystemDiskIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskIo, descrMetricSystemDiskIo, + unitMetricSystemDiskIo); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricSystemDiskIo( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemDiskIo, descrMetricSystemDiskIo, + unitMetricSystemDiskIo); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricSystemDiskIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemDiskIo, descrMetricSystemDiskIo, + unitMetricSystemDiskIo); +} + +/** + * Time disk spent activated + *

        + * The real elapsed time ("wall clock") used in the I/O path (time from operations running in + * parallel are not counted). Measured as:

        + * counter + */ +static constexpr const char *kMetricSystemDiskIoTime = "metric.system.disk.io_time"; +static constexpr const char *descrMetricSystemDiskIoTime = "Time disk spent activated"; +static constexpr const char *unitMetricSystemDiskIoTime = "s"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskIoTime( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskIoTime, descrMetricSystemDiskIoTime, + unitMetricSystemDiskIoTime); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemDiskIoTime( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskIoTime, descrMetricSystemDiskIoTime, + unitMetricSystemDiskIoTime); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskIoTime(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemDiskIoTime, descrMetricSystemDiskIoTime, + unitMetricSystemDiskIoTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskIoTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemDiskIoTime, descrMetricSystemDiskIoTime, + unitMetricSystemDiskIoTime); +} + +/** + * The total storage capacity of the disk + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemDiskLimit = "metric.system.disk.limit"; +static constexpr const char *descrMetricSystemDiskLimit = "The total storage capacity of the disk"; +static constexpr const char *unitMetricSystemDiskLimit = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemDiskLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemDiskLimit, descrMetricSystemDiskLimit, + unitMetricSystemDiskLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemDiskLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemDiskLimit, descrMetricSystemDiskLimit, + unitMetricSystemDiskLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemDiskLimit, descrMetricSystemDiskLimit, unitMetricSystemDiskLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemDiskLimit, descrMetricSystemDiskLimit, unitMetricSystemDiskLimit); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemDiskMerged = "metric.system.disk.merged"; +static constexpr const char *descrMetricSystemDiskMerged = ""; +static constexpr const char *unitMetricSystemDiskMerged = "{operation}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskMerged( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskMerged, descrMetricSystemDiskMerged, + unitMetricSystemDiskMerged); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemDiskMerged( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskMerged, descrMetricSystemDiskMerged, + unitMetricSystemDiskMerged); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskMerged(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemDiskMerged, descrMetricSystemDiskMerged, + unitMetricSystemDiskMerged); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskMerged(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemDiskMerged, descrMetricSystemDiskMerged, + unitMetricSystemDiskMerged); +} + +/** + * Sum of the time each operation took to complete + *

        + * Because it is the sum of time each request took, parallel-issued requests each contribute to make + * the count grow. Measured as:

        • Linux: Fields 7 & 11 from procfs-diskstats
        • + *
        • Windows: "Avg. Disk sec/Read" perf counter multiplied by "Disk Reads/sec" perf counter + * (similar for Writes)
        • + *
        + * counter + */ +static constexpr const char *kMetricSystemDiskOperationTime = "metric.system.disk.operation_time"; +static constexpr const char *descrMetricSystemDiskOperationTime = + "Sum of the time each operation took to complete"; +static constexpr const char *unitMetricSystemDiskOperationTime = "s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemDiskOperationTime(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskOperationTime, + descrMetricSystemDiskOperationTime, + unitMetricSystemDiskOperationTime); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemDiskOperationTime(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskOperationTime, + descrMetricSystemDiskOperationTime, + unitMetricSystemDiskOperationTime); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskOperationTime(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemDiskOperationTime, + descrMetricSystemDiskOperationTime, + unitMetricSystemDiskOperationTime); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskOperationTime(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemDiskOperationTime, + descrMetricSystemDiskOperationTime, + unitMetricSystemDiskOperationTime); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemDiskOperations = "metric.system.disk.operations"; +static constexpr const char *descrMetricSystemDiskOperations = ""; +static constexpr const char *unitMetricSystemDiskOperations = "{operation}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemDiskOperations(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemDiskOperations, descrMetricSystemDiskOperations, + unitMetricSystemDiskOperations); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemDiskOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemDiskOperations, descrMetricSystemDiskOperations, + unitMetricSystemDiskOperations); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemDiskOperations(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemDiskOperations, descrMetricSystemDiskOperations, unitMetricSystemDiskOperations); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemDiskOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemDiskOperations, descrMetricSystemDiskOperations, unitMetricSystemDiskOperations); +} + +/** + * The total storage capacity of the filesystem + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemFilesystemLimit = "metric.system.filesystem.limit"; +static constexpr const char *descrMetricSystemFilesystemLimit = + "The total storage capacity of the filesystem"; +static constexpr const char *unitMetricSystemFilesystemLimit = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemFilesystemLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemFilesystemLimit, + descrMetricSystemFilesystemLimit, + unitMetricSystemFilesystemLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemFilesystemLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemFilesystemLimit, + descrMetricSystemFilesystemLimit, + unitMetricSystemFilesystemLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemFilesystemLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemFilesystemLimit, + descrMetricSystemFilesystemLimit, + unitMetricSystemFilesystemLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemFilesystemLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemFilesystemLimit, + descrMetricSystemFilesystemLimit, + unitMetricSystemFilesystemLimit); +} + +/** + * Reports a filesystem's space usage across different states. + *

        + * The sum of all @code system.filesystem.usage @endcode values over the different @code + * system.filesystem.state @endcode attributes SHOULD equal the total storage capacity of the + * filesystem, that is @code system.filesystem.limit @endcode.

        updowncounter + */ +static constexpr const char *kMetricSystemFilesystemUsage = "metric.system.filesystem.usage"; +static constexpr const char *descrMetricSystemFilesystemUsage = + "Reports a filesystem's space usage across different states."; +static constexpr const char *unitMetricSystemFilesystemUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemFilesystemUsage, + descrMetricSystemFilesystemUsage, + unitMetricSystemFilesystemUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemFilesystemUsage, + descrMetricSystemFilesystemUsage, + unitMetricSystemFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemFilesystemUsage, + descrMetricSystemFilesystemUsage, + unitMetricSystemFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemFilesystemUsage, + descrMetricSystemFilesystemUsage, + unitMetricSystemFilesystemUsage); +} + +/** + * gauge + */ +static constexpr const char *kMetricSystemFilesystemUtilization = + "metric.system.filesystem.utilization"; +static constexpr const char *descrMetricSystemFilesystemUtilization = ""; +static constexpr const char *unitMetricSystemFilesystemUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemFilesystemUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemFilesystemUtilization, + descrMetricSystemFilesystemUtilization, + unitMetricSystemFilesystemUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemFilesystemUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemFilesystemUtilization, + descrMetricSystemFilesystemUtilization, + unitMetricSystemFilesystemUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemFilesystemUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemFilesystemUtilization, + descrMetricSystemFilesystemUtilization, + unitMetricSystemFilesystemUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemFilesystemUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricSystemFilesystemUtilization, + descrMetricSystemFilesystemUtilization, + unitMetricSystemFilesystemUtilization); +} + +/** + * An estimate of how much memory is available for starting new applications, without causing + * swapping

        This is an alternative to @code system.memory.usage @endcode metric with @code + * state=free @endcode. Linux starting from 3.14 exports "available" memory. It takes "free" memory + * as a baseline, and then factors in kernel-specific values. This is supposed to be more accurate + * than just "free" memory. For reference, see the calculations here. See also @code MemAvailable @endcode in /proc/meminfo.

        updowncounter + */ +static constexpr const char *kMetricSystemLinuxMemoryAvailable = + "metric.system.linux.memory.available"; +static constexpr const char *descrMetricSystemLinuxMemoryAvailable = + "An estimate of how much memory is available for starting new applications, without causing " + "swapping"; +static constexpr const char *unitMetricSystemLinuxMemoryAvailable = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemLinuxMemoryAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemLinuxMemoryAvailable, + descrMetricSystemLinuxMemoryAvailable, + unitMetricSystemLinuxMemoryAvailable); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemLinuxMemoryAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemLinuxMemoryAvailable, + descrMetricSystemLinuxMemoryAvailable, + unitMetricSystemLinuxMemoryAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemLinuxMemoryAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemLinuxMemoryAvailable, + descrMetricSystemLinuxMemoryAvailable, + unitMetricSystemLinuxMemoryAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemLinuxMemoryAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemLinuxMemoryAvailable, + descrMetricSystemLinuxMemoryAvailable, + unitMetricSystemLinuxMemoryAvailable); +} + +/** + * Reports the memory used by the Linux kernel for managing caches of frequently used objects. + *

        + * The sum over the @code reclaimable @endcode and @code unreclaimable @endcode state values in + * @code linux.memory.slab.usage @endcode SHOULD be equal to the total slab memory available on the + * system. Note that the total slab memory is not constant and may vary over time. See also the Slab + * allocator and @code Slab @endcode in /proc/meminfo.

        updowncounter + */ +static constexpr const char *kMetricSystemLinuxMemorySlabUsage = + "metric.system.linux.memory.slab.usage"; +static constexpr const char *descrMetricSystemLinuxMemorySlabUsage = + "Reports the memory used by the Linux kernel for managing caches of frequently used objects."; +static constexpr const char *unitMetricSystemLinuxMemorySlabUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemLinuxMemorySlabUsage, + descrMetricSystemLinuxMemorySlabUsage, + unitMetricSystemLinuxMemorySlabUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemLinuxMemorySlabUsage, + descrMetricSystemLinuxMemorySlabUsage, + unitMetricSystemLinuxMemorySlabUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemLinuxMemorySlabUsage, + descrMetricSystemLinuxMemorySlabUsage, + unitMetricSystemLinuxMemorySlabUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemLinuxMemorySlabUsage, + descrMetricSystemLinuxMemorySlabUsage, + unitMetricSystemLinuxMemorySlabUsage); +} + +/** + * Total memory available in the system. + *

        + * Its value SHOULD equal the sum of @code system.memory.state @endcode over all states. + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemMemoryLimit = "metric.system.memory.limit"; +static constexpr const char *descrMetricSystemMemoryLimit = "Total memory available in the system."; +static constexpr const char *unitMetricSystemMemoryLimit = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemMemoryLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemMemoryLimit, descrMetricSystemMemoryLimit, + unitMetricSystemMemoryLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemMemoryLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemMemoryLimit, descrMetricSystemMemoryLimit, + unitMetricSystemMemoryLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemMemoryLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemMemoryLimit, descrMetricSystemMemoryLimit, unitMetricSystemMemoryLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemMemoryLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemMemoryLimit, descrMetricSystemMemoryLimit, unitMetricSystemMemoryLimit); +} + +/** + * Shared memory used (mostly by tmpfs). + *

        + * Equivalent of @code shared @endcode from @code free @endcode command or + * @code Shmem @endcode from @code + * /proc/meminfo @endcode"

        updowncounter + */ +static constexpr const char *kMetricSystemMemoryShared = "metric.system.memory.shared"; +static constexpr const char *descrMetricSystemMemoryShared = + "Shared memory used (mostly by tmpfs)."; +static constexpr const char *unitMetricSystemMemoryShared = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemMemoryShared(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemMemoryShared, descrMetricSystemMemoryShared, + unitMetricSystemMemoryShared); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemMemoryShared(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemMemoryShared, descrMetricSystemMemoryShared, + unitMetricSystemMemoryShared); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemMemoryShared(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemMemoryShared, descrMetricSystemMemoryShared, unitMetricSystemMemoryShared); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemMemoryShared(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemMemoryShared, descrMetricSystemMemoryShared, unitMetricSystemMemoryShared); +} + +/** + * Reports memory in use by state. + *

        + * The sum over all @code system.memory.state @endcode values SHOULD equal the total memory + * available on the system, that is @code system.memory.limit @endcode. + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemMemoryUsage = "metric.system.memory.usage"; +static constexpr const char *descrMetricSystemMemoryUsage = "Reports memory in use by state."; +static constexpr const char *unitMetricSystemMemoryUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemMemoryUsage, descrMetricSystemMemoryUsage, + unitMetricSystemMemoryUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemMemoryUsage, descrMetricSystemMemoryUsage, + unitMetricSystemMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemMemoryUsage, descrMetricSystemMemoryUsage, unitMetricSystemMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemMemoryUsage, descrMetricSystemMemoryUsage, unitMetricSystemMemoryUsage); +} + +/** + * gauge + */ +static constexpr const char *kMetricSystemMemoryUtilization = "metric.system.memory.utilization"; +static constexpr const char *descrMetricSystemMemoryUtilization = ""; +static constexpr const char *unitMetricSystemMemoryUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemMemoryUtilization, descrMetricSystemMemoryUtilization, + unitMetricSystemMemoryUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemMemoryUtilization, + descrMetricSystemMemoryUtilization, + unitMetricSystemMemoryUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemMemoryUtilization, + descrMetricSystemMemoryUtilization, + unitMetricSystemMemoryUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricSystemMemoryUtilization, + descrMetricSystemMemoryUtilization, + unitMetricSystemMemoryUtilization); +} + +/** + * updowncounter + */ +static constexpr const char *kMetricSystemNetworkConnections = "metric.system.network.connections"; +static constexpr const char *descrMetricSystemNetworkConnections = ""; +static constexpr const char *unitMetricSystemNetworkConnections = "{connection}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkConnections(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemNetworkConnections, + descrMetricSystemNetworkConnections, + unitMetricSystemNetworkConnections); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemNetworkConnections(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemNetworkConnections, + descrMetricSystemNetworkConnections, + unitMetricSystemNetworkConnections); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkConnections(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricSystemNetworkConnections, + descrMetricSystemNetworkConnections, + unitMetricSystemNetworkConnections); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkConnections(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricSystemNetworkConnections, + descrMetricSystemNetworkConnections, + unitMetricSystemNetworkConnections); +} + +/** + * Count of packets that are dropped or discarded even though there was no error + *

        + * Measured as: + *

        + *

        + * counter + */ +static constexpr const char *kMetricSystemNetworkDropped = "metric.system.network.dropped"; +static constexpr const char *descrMetricSystemNetworkDropped = + "Count of packets that are dropped or discarded even though there was no error"; +static constexpr const char *unitMetricSystemNetworkDropped = "{packet}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkDropped(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, + unitMetricSystemNetworkDropped); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemNetworkDropped(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, + unitMetricSystemNetworkDropped); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkDropped(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, unitMetricSystemNetworkDropped); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkDropped(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, unitMetricSystemNetworkDropped); +} + +/** + * Count of network errors detected + *

        + * Measured as: + *

        + *

        + * counter + */ +static constexpr const char *kMetricSystemNetworkErrors = "metric.system.network.errors"; +static constexpr const char *descrMetricSystemNetworkErrors = "Count of network errors detected"; +static constexpr const char *unitMetricSystemNetworkErrors = "{error}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkErrors, descrMetricSystemNetworkErrors, + unitMetricSystemNetworkErrors); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemNetworkErrors( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkErrors, descrMetricSystemNetworkErrors, + unitMetricSystemNetworkErrors); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemNetworkErrors, descrMetricSystemNetworkErrors, unitMetricSystemNetworkErrors); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkErrors(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemNetworkErrors, descrMetricSystemNetworkErrors, unitMetricSystemNetworkErrors); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemNetworkIo = "metric.system.network.io"; +static constexpr const char *descrMetricSystemNetworkIo = ""; +static constexpr const char *unitMetricSystemNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkIo, descrMetricSystemNetworkIo, + unitMetricSystemNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkIo, descrMetricSystemNetworkIo, + unitMetricSystemNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkIo(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemNetworkIo, descrMetricSystemNetworkIo, + unitMetricSystemNetworkIo); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkIo(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemNetworkIo, descrMetricSystemNetworkIo, + unitMetricSystemNetworkIo); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemNetworkPackets = "metric.system.network.packets"; +static constexpr const char *descrMetricSystemNetworkPackets = ""; +static constexpr const char *unitMetricSystemNetworkPackets = "{packet}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, + unitMetricSystemNetworkPackets); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, + unitMetricSystemNetworkPackets); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, unitMetricSystemNetworkPackets); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, unitMetricSystemNetworkPackets); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemPagingFaults = "metric.system.paging.faults"; +static constexpr const char *descrMetricSystemPagingFaults = ""; +static constexpr const char *unitMetricSystemPagingFaults = "{fault}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricSystemPagingFaults( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemPagingFaults, descrMetricSystemPagingFaults, + unitMetricSystemPagingFaults); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricSystemPagingFaults( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemPagingFaults, descrMetricSystemPagingFaults, + unitMetricSystemPagingFaults); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemPagingFaults(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemPagingFaults, descrMetricSystemPagingFaults, unitMetricSystemPagingFaults); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemPagingFaults(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemPagingFaults, descrMetricSystemPagingFaults, unitMetricSystemPagingFaults); +} + +/** + * counter + */ +static constexpr const char *kMetricSystemPagingOperations = "metric.system.paging.operations"; +static constexpr const char *descrMetricSystemPagingOperations = ""; +static constexpr const char *unitMetricSystemPagingOperations = "{operation}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemPagingOperations(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemPagingOperations, + descrMetricSystemPagingOperations, + unitMetricSystemPagingOperations); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemPagingOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemPagingOperations, + descrMetricSystemPagingOperations, + unitMetricSystemPagingOperations); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemPagingOperations(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemPagingOperations, + descrMetricSystemPagingOperations, + unitMetricSystemPagingOperations); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemPagingOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemPagingOperations, + descrMetricSystemPagingOperations, + unitMetricSystemPagingOperations); +} + +/** + * Unix swap or windows pagefile usage + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemPagingUsage = "metric.system.paging.usage"; +static constexpr const char *descrMetricSystemPagingUsage = "Unix swap or windows pagefile usage"; +static constexpr const char *unitMetricSystemPagingUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemPagingUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemPagingUsage, descrMetricSystemPagingUsage, + unitMetricSystemPagingUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemPagingUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemPagingUsage, descrMetricSystemPagingUsage, + unitMetricSystemPagingUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemPagingUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemPagingUsage, descrMetricSystemPagingUsage, unitMetricSystemPagingUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemPagingUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemPagingUsage, descrMetricSystemPagingUsage, unitMetricSystemPagingUsage); +} + +/** + * gauge + */ +static constexpr const char *kMetricSystemPagingUtilization = "metric.system.paging.utilization"; +static constexpr const char *descrMetricSystemPagingUtilization = ""; +static constexpr const char *unitMetricSystemPagingUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemPagingUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricSystemPagingUtilization, descrMetricSystemPagingUtilization, + unitMetricSystemPagingUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemPagingUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricSystemPagingUtilization, + descrMetricSystemPagingUtilization, + unitMetricSystemPagingUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemPagingUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricSystemPagingUtilization, + descrMetricSystemPagingUtilization, + unitMetricSystemPagingUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemPagingUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricSystemPagingUtilization, + descrMetricSystemPagingUtilization, + unitMetricSystemPagingUtilization); +} + +/** + * Total number of processes in each state + *

        + * updowncounter + */ +static constexpr const char *kMetricSystemProcessCount = "metric.system.process.count"; +static constexpr const char *descrMetricSystemProcessCount = + "Total number of processes in each state"; +static constexpr const char *unitMetricSystemProcessCount = "{process}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemProcessCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricSystemProcessCount, descrMetricSystemProcessCount, + unitMetricSystemProcessCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemProcessCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricSystemProcessCount, descrMetricSystemProcessCount, + unitMetricSystemProcessCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemProcessCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricSystemProcessCount, descrMetricSystemProcessCount, unitMetricSystemProcessCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemProcessCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricSystemProcessCount, descrMetricSystemProcessCount, unitMetricSystemProcessCount); +} + +/** + * Total number of processes created over uptime of the host + *

        + * counter + */ +static constexpr const char *kMetricSystemProcessCreated = "metric.system.process.created"; +static constexpr const char *descrMetricSystemProcessCreated = + "Total number of processes created over uptime of the host"; +static constexpr const char *unitMetricSystemProcessCreated = "{process}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemProcessCreated(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemProcessCreated, descrMetricSystemProcessCreated, + unitMetricSystemProcessCreated); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemProcessCreated(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemProcessCreated, descrMetricSystemProcessCreated, + unitMetricSystemProcessCreated); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemProcessCreated(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter( + kMetricSystemProcessCreated, descrMetricSystemProcessCreated, unitMetricSystemProcessCreated); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemProcessCreated(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter( + kMetricSystemProcessCreated, descrMetricSystemProcessCreated, unitMetricSystemProcessCreated); +} + +} // namespace system +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h new file mode 100644 index 00000000000..5504febaba4 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h @@ -0,0 +1,125 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace telemetry +{ + +/** + * The name of the auto instrumentation agent or distribution, if used. + *

        + * Official auto instrumentation agents and distributions SHOULD set the @code telemetry.distro.name + * @endcode attribute to a string starting with @code opentelemetry- @endcode, e.g. @code + * opentelemetry-java-instrumentation @endcode. + */ +static constexpr const char *kTelemetryDistroName = "telemetry.distro.name"; + +/** + * The version string of the auto instrumentation agent or distribution, if used. + */ +static constexpr const char *kTelemetryDistroVersion = "telemetry.distro.version"; + +/** + * The language of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkLanguage = "telemetry.sdk.language"; + +/** + * The name of the telemetry SDK as defined above. + *

        + * The OpenTelemetry SDK MUST set the @code telemetry.sdk.name @endcode attribute to @code + * opentelemetry @endcode. If another SDK, like a fork or a vendor-provided implementation, is used, + * this SDK MUST set the + * @code telemetry.sdk.name @endcode attribute to the fully-qualified class or module name of this + * SDK's main entry point or another suitable identifier depending on the language. The identifier + * @code opentelemetry @endcode is reserved and MUST NOT be used in this case. All custom + * identifiers SHOULD be stable across different versions of an implementation. + */ +static constexpr const char *kTelemetrySdkName = "telemetry.sdk.name"; + +/** + * The version string of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; + +namespace TelemetrySdkLanguageValues +{ +/** + * none + */ +static constexpr const char *kCpp = "cpp"; + +/** + * none + */ +static constexpr const char *kDotnet = "dotnet"; + +/** + * none + */ +static constexpr const char *kErlang = "erlang"; + +/** + * none + */ +static constexpr const char *kGo = "go"; + +/** + * none + */ +static constexpr const char *kJava = "java"; + +/** + * none + */ +static constexpr const char *kNodejs = "nodejs"; + +/** + * none + */ +static constexpr const char *kPhp = "php"; + +/** + * none + */ +static constexpr const char *kPython = "python"; + +/** + * none + */ +static constexpr const char *kRuby = "ruby"; + +/** + * none + */ +static constexpr const char *kRust = "rust"; + +/** + * none + */ +static constexpr const char *kSwift = "swift"; + +/** + * none + */ +static constexpr const char *kWebjs = "webjs"; + +} // namespace TelemetrySdkLanguageValues + +} // namespace telemetry +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/test_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/test_attributes.h new file mode 100644 index 00000000000..dce482055c0 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/test_attributes.h @@ -0,0 +1,93 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace test +{ + +/** + * The fully qualified human readable name of the test case. + */ +static constexpr const char *kTestCaseName = "test.case.name"; + +/** + * The status of the actual test case result from test execution. + */ +static constexpr const char *kTestCaseResultStatus = "test.case.result.status"; + +/** + * The human readable name of a test suite. + */ +static constexpr const char *kTestSuiteName = "test.suite.name"; + +/** + * The status of the test suite run. + */ +static constexpr const char *kTestSuiteRunStatus = "test.suite.run.status"; + +namespace TestCaseResultStatusValues +{ +/** + * pass + */ +static constexpr const char *kPass = "pass"; + +/** + * fail + */ +static constexpr const char *kFail = "fail"; + +} // namespace TestCaseResultStatusValues + +namespace TestSuiteRunStatusValues +{ +/** + * success + */ +static constexpr const char *kSuccess = "success"; + +/** + * failure + */ +static constexpr const char *kFailure = "failure"; + +/** + * skipped + */ +static constexpr const char *kSkipped = "skipped"; + +/** + * aborted + */ +static constexpr const char *kAborted = "aborted"; + +/** + * timed_out + */ +static constexpr const char *kTimedOut = "timed_out"; + +/** + * in_progress + */ +static constexpr const char *kInProgress = "in_progress"; + +} // namespace TestSuiteRunStatusValues + +} // namespace test +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/thread_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/thread_attributes.h new file mode 100644 index 00000000000..8c053f84088 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/thread_attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace thread +{ + +/** + * Current "managed" thread ID (as opposed to OS thread ID). + */ +static constexpr const char *kThreadId = "thread.id"; + +/** + * Current thread name. + */ +static constexpr const char *kThreadName = "thread.name"; + +} // namespace thread +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/tls_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/tls_attributes.h new file mode 100644 index 00000000000..89449453ec9 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/tls_attributes.h @@ -0,0 +1,221 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace tls +{ + +/** + * String indicating the cipher used during the + * current connection.

        The values allowed for @code tls.cipher @endcode MUST be one of the @code + * Descriptions @endcode of the registered + * TLS Cipher Suits. + */ +static constexpr const char *kTlsCipher = "tls.cipher"; + +/** + * PEM-encoded stand-alone certificate offered by the client. This is usually mutually-exclusive of + * @code client.certificate_chain @endcode since this value also exists in that list. + */ +static constexpr const char *kTlsClientCertificate = "tls.client.certificate"; + +/** + * Array of PEM-encoded certificates that make up the certificate chain offered by the client. This + * is usually mutually-exclusive of @code client.certificate @endcode since that value should be the + * first certificate in the chain. + */ +static constexpr const char *kTlsClientCertificateChain = "tls.client.certificate_chain"; + +/** + * Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the + * client. For consistency with other hash values, this value should be formatted as an uppercase + * hash. + */ +static constexpr const char *kTlsClientHashMd5 = "tls.client.hash.md5"; + +/** + * Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by + * the client. For consistency with other hash values, this value should be formatted as an + * uppercase hash. + */ +static constexpr const char *kTlsClientHashSha1 = "tls.client.hash.sha1"; + +/** + * Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by + * the client. For consistency with other hash values, this value should be formatted as an + * uppercase hash. + */ +static constexpr const char *kTlsClientHashSha256 = "tls.client.hash.sha256"; + +/** + * Distinguished name of subject of the issuer of + * the x.509 certificate presented by the client. + */ +static constexpr const char *kTlsClientIssuer = "tls.client.issuer"; + +/** + * A hash that identifies clients based on how they perform an SSL/TLS handshake. + */ +static constexpr const char *kTlsClientJa3 = "tls.client.ja3"; + +/** + * Date/Time indicating when client certificate is no longer considered valid. + */ +static constexpr const char *kTlsClientNotAfter = "tls.client.not_after"; + +/** + * Date/Time indicating when client certificate is first considered valid. + */ +static constexpr const char *kTlsClientNotBefore = "tls.client.not_before"; + +/** + * Deprecated, use @code server.address @endcode instead. + *

        + * @deprecated + * Replaced by @code server.address @endcode. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kTlsClientServerName = "tls.client.server_name"; + +/** + * Distinguished name of subject of the x.509 certificate presented by the client. + */ +static constexpr const char *kTlsClientSubject = "tls.client.subject"; + +/** + * Array of ciphers offered by the client during the client hello. + */ +static constexpr const char *kTlsClientSupportedCiphers = "tls.client.supported_ciphers"; + +/** + * String indicating the curve used for the given cipher, when applicable + */ +static constexpr const char *kTlsCurve = "tls.curve"; + +/** + * Boolean flag indicating if the TLS negotiation was successful and transitioned to an encrypted + * tunnel. + */ +static constexpr const char *kTlsEstablished = "tls.established"; + +/** + * String indicating the protocol being tunneled. Per the values in the IANA + * registry, this string should be lower case. + */ +static constexpr const char *kTlsNextProtocol = "tls.next_protocol"; + +/** + * Normalized lowercase protocol name parsed from original string of the negotiated SSL/TLS + * protocol version + */ +static constexpr const char *kTlsProtocolName = "tls.protocol.name"; + +/** + * Numeric part of the version parsed from the original string of the negotiated SSL/TLS + * protocol version + */ +static constexpr const char *kTlsProtocolVersion = "tls.protocol.version"; + +/** + * Boolean flag indicating if this TLS connection was resumed from an existing TLS negotiation. + */ +static constexpr const char *kTlsResumed = "tls.resumed"; + +/** + * PEM-encoded stand-alone certificate offered by the server. This is usually mutually-exclusive of + * @code server.certificate_chain @endcode since this value also exists in that list. + */ +static constexpr const char *kTlsServerCertificate = "tls.server.certificate"; + +/** + * Array of PEM-encoded certificates that make up the certificate chain offered by the server. This + * is usually mutually-exclusive of @code server.certificate @endcode since that value should be the + * first certificate in the chain. + */ +static constexpr const char *kTlsServerCertificateChain = "tls.server.certificate_chain"; + +/** + * Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the + * server. For consistency with other hash values, this value should be formatted as an uppercase + * hash. + */ +static constexpr const char *kTlsServerHashMd5 = "tls.server.hash.md5"; + +/** + * Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by + * the server. For consistency with other hash values, this value should be formatted as an + * uppercase hash. + */ +static constexpr const char *kTlsServerHashSha1 = "tls.server.hash.sha1"; + +/** + * Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by + * the server. For consistency with other hash values, this value should be formatted as an + * uppercase hash. + */ +static constexpr const char *kTlsServerHashSha256 = "tls.server.hash.sha256"; + +/** + * Distinguished name of subject of the issuer of + * the x.509 certificate presented by the client. + */ +static constexpr const char *kTlsServerIssuer = "tls.server.issuer"; + +/** + * A hash that identifies servers based on how they perform an SSL/TLS handshake. + */ +static constexpr const char *kTlsServerJa3s = "tls.server.ja3s"; + +/** + * Date/Time indicating when server certificate is no longer considered valid. + */ +static constexpr const char *kTlsServerNotAfter = "tls.server.not_after"; + +/** + * Date/Time indicating when server certificate is first considered valid. + */ +static constexpr const char *kTlsServerNotBefore = "tls.server.not_before"; + +/** + * Distinguished name of subject of the x.509 certificate presented by the server. + */ +static constexpr const char *kTlsServerSubject = "tls.server.subject"; + +namespace TlsProtocolNameValues +{ +/** + * none + */ +static constexpr const char *kSsl = "ssl"; + +/** + * none + */ +static constexpr const char *kTls = "tls"; + +} // namespace TlsProtocolNameValues + +} // namespace tls +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/url_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/url_attributes.h new file mode 100644 index 00000000000..fb3418e26a2 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/url_attributes.h @@ -0,0 +1,137 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace url +{ + +/** + * Domain extracted from the @code url.full @endcode, such as "opentelemetry.io". + *

        + * In some cases a URL may refer to an IP and/or port directly, without a domain name. In this case, + * the IP address would go to the domain field. If the URL contains a literal IPv6 address enclosed by + * @code [ @endcode and @code ] @endcode, the @code [ @endcode and @code ] @endcode characters + * should also be captured in the domain field. + */ +static constexpr const char *kUrlDomain = "url.domain"; + +/** + * The file extension extracted from the @code url.full @endcode, excluding the leading dot. + *

        + * The file extension is only set if it exists, as not every url has a file extension. When the file + * name has multiple extensions @code example.tar.gz @endcode, only the last one should be captured + * @code gz @endcode, not @code tar.gz @endcode. + */ +static constexpr const char *kUrlExtension = "url.extension"; + +/** + * The URI fragment component + */ +static constexpr const char *kUrlFragment = "url.fragment"; + +/** + * Absolute URL describing a network resource according to RFC3986

        For network calls, URL usually has + * @code scheme://host[:port][path][?query][#fragment] @endcode format, where the fragment is not + * transmitted over HTTP, but if it is known, it SHOULD be included nevertheless. + * @code url.full @endcode MUST NOT contain credentials passed via URL in form of @code + * https://username:password@www.example.com/ @endcode. In such case username and password SHOULD be + * redacted and attribute's value SHOULD be @code https://REDACTED:REDACTED@www.example.com/ + * @endcode. + * @code url.full @endcode SHOULD capture the absolute URL when it is available (or can be + * reconstructed). Sensitive content provided in @code url.full @endcode SHOULD be scrubbed when + * instrumentations can identify it. + */ +static constexpr const char *kUrlFull = "url.full"; + +/** + * Unmodified original URL as seen in the event source. + *

        + * In network monitoring, the observed URL may be a full URL, whereas in access logs, the URL is + * often just represented as a path. This field is meant to represent the URL as it was observed, + * complete or not. + * @code url.original @endcode might contain credentials passed via URL in form of @code + * https://username:password@www.example.com/ @endcode. In such case password and username SHOULD + * NOT be redacted and attribute's value SHOULD remain the same. + */ +static constexpr const char *kUrlOriginal = "url.original"; + +/** + * The URI path component + *

        + * Sensitive content provided in @code url.path @endcode SHOULD be scrubbed when instrumentations + * can identify it. + */ +static constexpr const char *kUrlPath = "url.path"; + +/** + * Port extracted from the @code url.full @endcode + */ +static constexpr const char *kUrlPort = "url.port"; + +/** + * The URI query component + *

        + * Sensitive content provided in @code url.query @endcode SHOULD be scrubbed when instrumentations + * can identify it. + */ +static constexpr const char *kUrlQuery = "url.query"; + +/** + * The highest registered url domain, stripped of the subdomain. + *

        + * This value can be determined precisely with the public suffix + * list. For example, the registered domain for @code foo.example.com @endcode is @code + * example.com @endcode. Trying to approximate this by simply taking the last two labels will not + * work well for TLDs such as @code co.uk @endcode. + */ +static constexpr const char *kUrlRegisteredDomain = "url.registered_domain"; + +/** + * The URI scheme component + * identifying the used protocol. + */ +static constexpr const char *kUrlScheme = "url.scheme"; + +/** + * The subdomain portion of a fully qualified domain name includes all of the names except the host + * name under the registered_domain. In a partially qualified domain, or if the qualification level + * of the full name cannot be determined, subdomain contains all of the names below the registered + * domain.

        The subdomain portion of @code www.east.mydomain.co.uk @endcode is @code east + * @endcode. If the domain has multiple levels of subdomain, such as @code sub2.sub1.example.com + * @endcode, the subdomain field should contain @code sub2.sub1 @endcode, with no trailing period. + */ +static constexpr const char *kUrlSubdomain = "url.subdomain"; + +/** + * The low-cardinality template of an absolute path reference. + */ +static constexpr const char *kUrlTemplate = "url.template"; + +/** + * The effective top level domain (eTLD), also known as the domain suffix, is the last part of the + * domain name. For example, the top level domain for example.com is @code com @endcode.

        This + * value can be determined precisely with the public suffix + * list. + */ +static constexpr const char *kUrlTopLevelDomain = "url.top_level_domain"; + +} // namespace url +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h new file mode 100644 index 00000000000..738bb6de15b --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h @@ -0,0 +1,51 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace user_agent +{ + +/** + * Name of the user-agent extracted from original. Usually refers to the browser's name. + *

        + * Example of extracting browser's name from original + * string. In the case of using a user-agent for non-browser products, such as microservices with + * multiple names/versions inside the @code user_agent.original @endcode, the most significant name + * SHOULD be selected. In such a scenario it should align with @code user_agent.version @endcode + */ +static constexpr const char *kUserAgentName = "user_agent.name"; + +/** + * Value of the HTTP + * User-Agent header sent by the client. + */ +static constexpr const char *kUserAgentOriginal = "user_agent.original"; + +/** + * Version of the user-agent extracted from original. Usually refers to the browser's version + *

        + * Example of extracting browser's version from original + * string. In the case of using a user-agent for non-browser products, such as microservices with + * multiple names/versions inside the @code user_agent.original @endcode, the most significant + * version SHOULD be selected. In such a scenario it should align with @code user_agent.name + * @endcode + */ +static constexpr const char *kUserAgentVersion = "user_agent.version"; + +} // namespace user_agent +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/user_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/user_attributes.h new file mode 100644 index 00000000000..cc5a80d069c --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/user_attributes.h @@ -0,0 +1,57 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace user +{ + +/** + * User email address. + */ +static constexpr const char *kUserEmail = "user.email"; + +/** + * User's full name + */ +static constexpr const char *kUserFullName = "user.full_name"; + +/** + * Unique user hash to correlate information for a user in anonymized form. + *

        + * Useful if @code user.id @endcode or @code user.name @endcode contain confidential information and + * cannot be used. + */ +static constexpr const char *kUserHash = "user.hash"; + +/** + * Unique identifier of the user. + */ +static constexpr const char *kUserId = "user.id"; + +/** + * Short name or login/username of the user. + */ +static constexpr const char *kUserName = "user.name"; + +/** + * Array of user roles at the time of the event. + */ +static constexpr const char *kUserRoles = "user.roles"; + +} // namespace user +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_attributes.h new file mode 100644 index 00000000000..cc38902e889 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_attributes.h @@ -0,0 +1,86 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace vcs +{ + +/** + * The ID of the change (pull request/merge request) if applicable. This is usually a unique (within + * repository) identifier generated by the VCS system. + */ +static constexpr const char *kVcsRepositoryChangeId = "vcs.repository.change.id"; + +/** + * The human readable title of the change (pull request/merge request). This title is often a brief + * summary of the change and may get merged in to a ref as the commit summary. + */ +static constexpr const char *kVcsRepositoryChangeTitle = "vcs.repository.change.title"; + +/** + * The name of the reference such as + * branch or tag in the repository. + */ +static constexpr const char *kVcsRepositoryRefName = "vcs.repository.ref.name"; + +/** + * The revision, literally revised + * version, The revision most often refers to a commit object in Git, or a revision number in + * SVN.

        The revision can be a full hash value (see glossary), + * of the recorded change to a ref within a repository pointing to a + * commit commit object. It does + * not necessarily have to be a hash; it can simply define a + * revision number + * which is an integer that is monotonically increasing. In cases where + * it is identical to the @code ref.name @endcode, it SHOULD still be included. It is + * up to the implementer to decide which value to set as the revision + * based on the VCS system and situational context. + */ +static constexpr const char *kVcsRepositoryRefRevision = "vcs.repository.ref.revision"; + +/** + * The type of the reference in the + * repository. + */ +static constexpr const char *kVcsRepositoryRefType = "vcs.repository.ref.type"; + +/** + * The URL of the repository providing the complete + * address in order to locate and identify the repository. + */ +static constexpr const char *kVcsRepositoryUrlFull = "vcs.repository.url.full"; + +namespace VcsRepositoryRefTypeValues +{ +/** + * branch + */ +static constexpr const char *kBranch = "branch"; + +/** + * tag + */ +static constexpr const char *kTag = "tag"; + +} // namespace VcsRepositoryRefTypeValues + +} // namespace vcs +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/webengine_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/webengine_attributes.h new file mode 100644 index 00000000000..16283b43cb8 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/webengine_attributes.h @@ -0,0 +1,39 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace webengine +{ + +/** + * 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. + */ +static constexpr const char *kWebengineName = "webengine.name"; + +/** + * The version of the web engine. + */ +static constexpr const char *kWebengineVersion = "webengine.version"; + +} // namespace webengine +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/network_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/network_attributes.h new file mode 100644 index 00000000000..7e965e6a6ec --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/network_attributes.h @@ -0,0 +1,120 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace network +{ + +/** + * Local address of the network connection - IP address or Unix domain socket name. + */ +static constexpr const char *kNetworkLocalAddress = "network.local.address"; + +/** + * Local port number of the network connection. + */ +static constexpr const char *kNetworkLocalPort = "network.local.port"; + +/** + * Peer address of the network connection - IP address or Unix domain socket name. + */ +static constexpr const char *kNetworkPeerAddress = "network.peer.address"; + +/** + * Peer port number of the network connection. + */ +static constexpr const char *kNetworkPeerPort = "network.peer.port"; + +/** + * OSI application layer or non-OSI + * equivalent.

        The value SHOULD be normalized to lowercase. + */ +static constexpr const char *kNetworkProtocolName = "network.protocol.name"; + +/** + * The actual version of the protocol used for network communication. + *

        + * If protocol version is subject to negotiation (for example using ALPN), this attribute SHOULD be set to the + * negotiated version. If the actual protocol version is not known, this attribute SHOULD NOT be + * set. + */ +static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; + +/** + * OSI transport layer or inter-process communication + * method.

        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 *kNetworkTransport = "network.transport"; + +/** + * OSI network layer or non-OSI equivalent. + *

        + * The value SHOULD be normalized to lowercase. + */ +static constexpr const char *kNetworkType = "network.type"; + +namespace NetworkTransportValues +{ +/** + * TCP + */ +static constexpr const char *kTcp = "tcp"; + +/** + * UDP + */ +static constexpr const char *kUdp = "udp"; + +/** + * Named or anonymous pipe. + */ +static constexpr const char *kPipe = "pipe"; + +/** + * Unix domain socket + */ +static constexpr const char *kUnix = "unix"; + +/** + * QUIC + */ +static constexpr const char *kQuic = "quic"; + +} // namespace NetworkTransportValues + +namespace NetworkTypeValues +{ +/** + * IPv4 + */ +static constexpr const char *kIpv4 = "ipv4"; + +/** + * IPv6 + */ +static constexpr const char *kIpv6 = "ipv6"; + +} // namespace NetworkTypeValues + +} // namespace network +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/otel_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/otel_attributes.h new file mode 100644 index 00000000000..b92eff1dd44 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/otel_attributes.h @@ -0,0 +1,59 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace otel +{ + +/** + * The name of the instrumentation scope - (@code InstrumentationScope.Name @endcode in OTLP). + */ +static constexpr const char *kOtelScopeName = "otel.scope.name"; + +/** + * The version of the instrumentation scope - (@code InstrumentationScope.Version @endcode in OTLP). + */ +static constexpr const char *kOtelScopeVersion = "otel.scope.version"; + +/** + * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code is UNSET. + */ +static constexpr const char *kOtelStatusCode = "otel.status_code"; + +/** + * Description of the Status if it has a value, otherwise not set. + */ +static constexpr const char *kOtelStatusDescription = "otel.status_description"; + +namespace OtelStatusCodeValues +{ +/** + * The operation has been validated by an Application developer or Operator to have completed + * successfully. + */ +static constexpr const char *kOk = "OK"; + +/** + * The operation contains an error. + */ +static constexpr const char *kError = "ERROR"; + +} // namespace OtelStatusCodeValues + +} // namespace otel +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/schema_url.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/schema_url.h new file mode 100644 index 00000000000..a25e28b5ea9 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/schema_url.h @@ -0,0 +1,24 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/schema_url-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +/** + * The URL of the OpenTelemetry schema for these keys and values. + */ +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.28.0"; +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/server_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/server_attributes.h new file mode 100644 index 00000000000..21cb75d729a --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/server_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace server +{ + +/** + * Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain + * socket name.

        When observed from the client side, and when communicating through an + * intermediary, @code server.address @endcode SHOULD represent the server address behind any + * intermediaries, for example proxies, if it's available. + */ +static constexpr const char *kServerAddress = "server.address"; + +/** + * Server port number. + *

        + * When observed from the client side, and when communicating through an intermediary, @code + * server.port @endcode SHOULD represent the server port behind any intermediaries, for example + * proxies, if it's available. + */ +static constexpr const char *kServerPort = "server.port"; + +} // namespace server +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/service_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/service_attributes.h new file mode 100644 index 00000000000..e4c0dda17a2 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/service_attributes.h @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace service +{ + +/** + * Logical name of the service. + *

        + * MUST be the same for all instances of horizontally scaled services. If the value was not + * specified, SDKs MUST fallback to @code unknown_service: @endcode concatenated with @code process.executable.name @endcode, e.g. @code unknown_service:bash + * @endcode. If @code process.executable.name @endcode is not available, the value MUST be set to + * @code unknown_service @endcode. + */ +static constexpr const char *kServiceName = "service.name"; + +/** + * The version string of the service API or implementation. The format is not defined by these + * conventions. + */ +static constexpr const char *kServiceVersion = "service.version"; + +} // namespace service +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h new file mode 100644 index 00000000000..7aa764cdaa4 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h @@ -0,0 +1,111 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace telemetry +{ + +/** + * The language of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkLanguage = "telemetry.sdk.language"; + +/** + * The name of the telemetry SDK as defined above. + *

        + * The OpenTelemetry SDK MUST set the @code telemetry.sdk.name @endcode attribute to @code + * opentelemetry @endcode. If another SDK, like a fork or a vendor-provided implementation, is used, + * this SDK MUST set the + * @code telemetry.sdk.name @endcode attribute to the fully-qualified class or module name of this + * SDK's main entry point or another suitable identifier depending on the language. The identifier + * @code opentelemetry @endcode is reserved and MUST NOT be used in this case. All custom + * identifiers SHOULD be stable across different versions of an implementation. + */ +static constexpr const char *kTelemetrySdkName = "telemetry.sdk.name"; + +/** + * The version string of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; + +namespace TelemetrySdkLanguageValues +{ +/** + * none + */ +static constexpr const char *kCpp = "cpp"; + +/** + * none + */ +static constexpr const char *kDotnet = "dotnet"; + +/** + * none + */ +static constexpr const char *kErlang = "erlang"; + +/** + * none + */ +static constexpr const char *kGo = "go"; + +/** + * none + */ +static constexpr const char *kJava = "java"; + +/** + * none + */ +static constexpr const char *kNodejs = "nodejs"; + +/** + * none + */ +static constexpr const char *kPhp = "php"; + +/** + * none + */ +static constexpr const char *kPython = "python"; + +/** + * none + */ +static constexpr const char *kRuby = "ruby"; + +/** + * none + */ +static constexpr const char *kRust = "rust"; + +/** + * none + */ +static constexpr const char *kSwift = "swift"; + +/** + * none + */ +static constexpr const char *kWebjs = "webjs"; + +} // namespace TelemetrySdkLanguageValues + +} // namespace telemetry +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/url_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/url_attributes.h new file mode 100644 index 00000000000..25ed5b03ab9 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/url_attributes.h @@ -0,0 +1,66 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace url +{ + +/** + * The URI fragment component + */ +static constexpr const char *kUrlFragment = "url.fragment"; + +/** + * Absolute URL describing a network resource according to RFC3986

        For network calls, URL usually has + * @code scheme://host[:port][path][?query][#fragment] @endcode format, where the fragment is not + * transmitted over HTTP, but if it is known, it SHOULD be included nevertheless. + * @code url.full @endcode MUST NOT contain credentials passed via URL in form of @code + * https://username:password@www.example.com/ @endcode. In such case username and password SHOULD be + * redacted and attribute's value SHOULD be @code https://REDACTED:REDACTED@www.example.com/ + * @endcode. + * @code url.full @endcode SHOULD capture the absolute URL when it is available (or can be + * reconstructed). Sensitive content provided in @code url.full @endcode SHOULD be scrubbed when + * instrumentations can identify it. + */ +static constexpr const char *kUrlFull = "url.full"; + +/** + * The URI path component + *

        + * Sensitive content provided in @code url.path @endcode SHOULD be scrubbed when instrumentations + * can identify it. + */ +static constexpr const char *kUrlPath = "url.path"; + +/** + * The URI query component + *

        + * Sensitive content provided in @code url.query @endcode SHOULD be scrubbed when instrumentations + * can identify it. + */ +static constexpr const char *kUrlQuery = "url.query"; + +/** + * The URI scheme component + * identifying the used protocol. + */ +static constexpr const char *kUrlScheme = "url.scheme"; + +} // namespace url +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/user_agent_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/user_agent_attributes.h new file mode 100644 index 00000000000..dd1d4932786 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/user_agent_attributes.h @@ -0,0 +1,30 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace user_agent +{ + +/** + * Value of the HTTP + * User-Agent header sent by the client. + */ +static constexpr const char *kUserAgentOriginal = "user_agent.original"; + +} // namespace user_agent +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/default_span.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/default_span.h index 7e3979501e2..7ad6a3726e4 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/default_span.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/default_span.h @@ -66,8 +66,8 @@ class DefaultSpan : public Span DefaultSpan(SpanContext span_context) noexcept : span_context_(span_context) {} // movable and copiable - DefaultSpan(DefaultSpan &&spn) noexcept : span_context_(spn.GetContext()) {} - DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.GetContext()) {} + DefaultSpan(DefaultSpan &&spn) noexcept : Span(), span_context_(spn.GetContext()) {} + DefaultSpan(const DefaultSpan &spn) noexcept : Span(), span_context_(spn.GetContext()) {} private: SpanContext span_context_; diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/propagation/http_trace_context.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/propagation/http_trace_context.h index a6b7e3b219c..81d4c308ec0 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/propagation/http_trace_context.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/propagation/http_trace_context.h @@ -86,14 +86,8 @@ class HttpTraceContext : public context::propagation::TextMapPropagator } private: - static constexpr uint8_t kInvalidVersion = 0xFF; - - static bool IsValidVersion(nostd::string_view version_hex) - { - uint8_t version; - detail::HexToBinary(version_hex, &version, sizeof(version)); - return version != kInvalidVersion; - } + static constexpr uint8_t kInvalidVersion = 0xFF; + static constexpr uint8_t kDefaultAssumedVersion = 0x00; static void InjectImpl(context::propagation::TextMapCarrier &carrier, const SpanContext &span_context) @@ -122,11 +116,6 @@ class HttpTraceContext : public context::propagation::TextMapPropagator static SpanContext ExtractContextFromTraceHeaders(nostd::string_view trace_parent, nostd::string_view trace_state) { - if (trace_parent.size() != kTraceParentSize) - { - return SpanContext::GetInvalid(); - } - std::array fields{}; if (detail::SplitString(trace_parent, '-', fields.data(), 4) != 4) { @@ -150,11 +139,33 @@ class HttpTraceContext : public context::propagation::TextMapPropagator return SpanContext::GetInvalid(); } - if (!IsValidVersion(version_hex)) + // hex is valid, convert it to binary + uint8_t version_binary; + detail::HexToBinary(version_hex, &version_binary, sizeof(version_binary)); + if (version_binary == kInvalidVersion) { + // invalid version encountered return SpanContext::GetInvalid(); } + // See https://www.w3.org/TR/trace-context/#versioning-of-traceparent + if (version_binary > kDefaultAssumedVersion) + { + // higher than default version detected + if (trace_parent.size() < kTraceParentSize) + { + return SpanContext::GetInvalid(); + } + } + else + { + // version is either lower or same as the default version + if (trace_parent.size() != kTraceParentSize) + { + return SpanContext::GetInvalid(); + } + } + TraceId trace_id = TraceIdFromHex(trace_id_hex); SpanId span_id = SpanIdFromHex(span_id_hex); @@ -169,7 +180,8 @@ class HttpTraceContext : public context::propagation::TextMapPropagator static SpanContext ExtractImpl(const context::propagation::TextMapCarrier &carrier) { - nostd::string_view trace_parent = carrier.Get(kTraceParent); + // Get trace_parent after trimming the leading and trailing whitespaces + nostd::string_view trace_parent = common::StringUtil::Trim(carrier.Get(kTraceParent)); nostd::string_view trace_state = carrier.Get(kTraceState); if (trace_parent == "") { diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/propagation/jaeger.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/propagation/jaeger.h index 1f0195a248b..45a93709193 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/propagation/jaeger.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/propagation/jaeger.h @@ -3,10 +3,6 @@ #pragma once -#ifdef OPENTELEMETRY_NO_DEPRECATED_CODE -# error "header is deprecated." -#endif - #include "detail/hex.h" #include "detail/string.h" #include "opentelemetry/context/propagation/text_map_propagator.h" @@ -21,7 +17,7 @@ namespace propagation static const nostd::string_view kJaegerTraceHeader = "uber-trace-id"; -class OPENTELEMETRY_DEPRECATED JaegerPropagator : public context::propagation::TextMapPropagator +class JaegerPropagator : public context::propagation::TextMapPropagator { public: void Inject(context::propagation::TextMapCarrier &carrier, diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/semantic_conventions.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/semantic_conventions.h index fb26385fbc5..d6d6591149a 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/semantic_conventions.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/semantic_conventions.h @@ -4,9 +4,13 @@ */ /* - DO NOT EDIT, this is an Auto-generated file - from buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 -*/ + * This file is DEPRECATED, and no longer updated. + * See file DEPRECATED.md for details. + */ + +#ifdef OPENTELEMETRY_NO_DEPRECATED_CODE +# error "header is deprecated." +#endif #pragma once diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/trace_state.h b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/trace_state.h index 753f48c99e0..df7a0e0fe9c 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/trace/trace_state.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/trace/trace_state.h @@ -59,7 +59,8 @@ class OPENTELEMETRY_EXPORT TraceState size_t cnt = kv_str_tokenizer.NumTokens(); // upper bound on number of kv pairs if (cnt > kMaxKeyValuePairs) { - cnt = kMaxKeyValuePairs; + // trace state should be discarded if count exceeds + return GetDefault(); } nostd::shared_ptr ts(new TraceState(cnt)); diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/version.h b/deps/opentelemetry-cpp/api/include/opentelemetry/version.h index d3e18ce1d8b..a26b8b4e88d 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/version.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/version.h @@ -10,9 +10,9 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.17.0" +#define OPENTELEMETRY_VERSION "1.18.0" #define OPENTELEMETRY_VERSION_MAJOR 1 -#define OPENTELEMETRY_VERSION_MINOR 17 +#define OPENTELEMETRY_VERSION_MINOR 18 #define OPENTELEMETRY_VERSION_PATCH 0 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/deps/opentelemetry-cpp/api/test/CMakeLists.txt b/deps/opentelemetry-cpp/api/test/CMakeLists.txt index 20c9f4e9492..66eeee20927 100644 --- a/deps/opentelemetry-cpp/api/test/CMakeLists.txt +++ b/deps/opentelemetry-cpp/api/test/CMakeLists.txt @@ -10,4 +10,7 @@ add_subdirectory(metrics) add_subdirectory(logs) add_subdirectory(common) add_subdirectory(baggage) -add_subdirectory(singleton) + +if(NOT OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS) + add_subdirectory(singleton) +endif() diff --git a/deps/opentelemetry-cpp/api/test/common/spinlock_benchmark.cc b/deps/opentelemetry-cpp/api/test/common/spinlock_benchmark.cc index b5e98a2108e..da588b7e30a 100644 --- a/deps/opentelemetry-cpp/api/test/common/spinlock_benchmark.cc +++ b/deps/opentelemetry-cpp/api/test/common/spinlock_benchmark.cc @@ -102,8 +102,10 @@ static void BM_ProcYieldSpinLockThrashing(benchmark::State &s) # else __builtin_ia32_pause(); # endif -#elif defined(__arm__) - __asm__ volatile("yield" ::: "memory"); +#elif defined(__armel__) || defined(__ARMEL__) + asm volatile("nop" ::: "memory"); +#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64 + __asm__ __volatile__("yield" ::: "memory"); #endif } }, diff --git a/deps/opentelemetry-cpp/api/test/common/string_util_test.cc b/deps/opentelemetry-cpp/api/test/common/string_util_test.cc index f074d4fbe3d..8746607766c 100644 --- a/deps/opentelemetry-cpp/api/test/common/string_util_test.cc +++ b/deps/opentelemetry-cpp/api/test/common/string_util_test.cc @@ -35,9 +35,15 @@ TEST(StringUtilTest, TrimString) {"k1=v1,k2=v2, k3=v3", "k1=v1,k2=v2, k3=v3"}, {" k1=v1", "k1=v1"}, {"k1=v1 ", "k1=v1"}, + {"k1=v1\t", "k1=v1"}, + {"\t k1=v1 \t", "k1=v1"}, + {"\t\t k1=v1\t ", "k1=v1"}, + {"\t\t k1=v1\t ,k2=v2", "k1=v1\t ,k2=v2"}, {" k1=v1 ", "k1=v1"}, {" ", ""}, - {"", ""}}; + {"", ""}, + {"\n_some string_\t", "_some string_"}}; + for (auto &testcase : testcases) { EXPECT_EQ(StringUtil::Trim(testcase.input), testcase.expected); diff --git a/deps/opentelemetry-cpp/api/test/trace/propagation/CMakeLists.txt b/deps/opentelemetry-cpp/api/test/trace/propagation/CMakeLists.txt index a1cfcf83eec..f55c7381658 100644 --- a/deps/opentelemetry-cpp/api/test/trace/propagation/CMakeLists.txt +++ b/deps/opentelemetry-cpp/api/test/trace/propagation/CMakeLists.txt @@ -3,7 +3,8 @@ add_subdirectory(detail) -foreach(testname http_text_format_test b3_propagation_test) +foreach(testname http_text_format_test b3_propagation_test + jaeger_propagation_test) add_executable(${testname} "${testname}.cc") target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) @@ -12,16 +13,3 @@ foreach(testname http_text_format_test b3_propagation_test) TEST_PREFIX trace. TEST_LIST ${testname}) endforeach() - -if(NOT WITH_NO_DEPRECATED_CODE) - foreach(testname jaeger_propagation_test) - - add_executable(${testname} "${testname}.cc") - target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) - gtest_add_tests( - TARGET ${testname} - TEST_PREFIX trace. - TEST_LIST ${testname}) - endforeach() -endif() diff --git a/deps/opentelemetry-cpp/api/test/trace/propagation/detail/BUILD b/deps/opentelemetry-cpp/api/test/trace/propagation/detail/BUILD index a082586650a..322c8929375 100644 --- a/deps/opentelemetry-cpp/api/test/trace/propagation/detail/BUILD +++ b/deps/opentelemetry-cpp/api/test/trace/propagation/detail/BUILD @@ -18,3 +18,19 @@ cc_test( "@com_google_googletest//:gtest_main", ], ) + +cc_test( + name = "string_test", + srcs = [ + "string_test.cc", + ], + tags = [ + "api", + "test", + "trace", + ], + deps = [ + "//api", + "@com_google_googletest//:gtest_main", + ], +) diff --git a/deps/opentelemetry-cpp/api/test/trace/propagation/detail/CMakeLists.txt b/deps/opentelemetry-cpp/api/test/trace/propagation/detail/CMakeLists.txt index 34e2f6ae408..c70478efa1e 100644 --- a/deps/opentelemetry-cpp/api/test/trace/propagation/detail/CMakeLists.txt +++ b/deps/opentelemetry-cpp/api/test/trace/propagation/detail/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -foreach(testname hex_test) +foreach(testname hex_test string_test) add_executable(${testname} "${testname}.cc") target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) diff --git a/deps/opentelemetry-cpp/api/test/trace/propagation/detail/string_test.cc b/deps/opentelemetry-cpp/api/test/trace/propagation/detail/string_test.cc new file mode 100644 index 00000000000..67a48a354c4 --- /dev/null +++ b/deps/opentelemetry-cpp/api/test/trace/propagation/detail/string_test.cc @@ -0,0 +1,62 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include + +#include "opentelemetry/nostd/string_view.h" + +using namespace opentelemetry; + +namespace +{ + +struct SplitStringTestData +{ + opentelemetry::nostd::string_view input; + char separator; + size_t max_count; + size_t expected_number_strings; + + // When googletest registers parameterized tests, it uses this method to format the parameters. + // The default implementation prints hex dump of all bytes in the object. If there is any padding + // in these bytes, valgrind reports this as a warning - "Use of uninitialized bytes". + // See https://github.com/google/googletest/issues/3805. + friend void PrintTo(const SplitStringTestData &data, std::ostream *os) + { + *os << "(" << data.input << "," << data.separator << "," << data.max_count << "," + << data.expected_number_strings << ")"; + } +}; + +const SplitStringTestData split_string_test_cases[] = { + {"foo,bar,baz", ',', 4, 3}, + {"foo,bar,baz,foobar", ',', 4, 4}, + {"foo,bar,baz,foobar", '.', 4, 1}, + {"foo,bar,baz,", ',', 4, 4}, + {"foo,bar,baz,", ',', 2, 2}, + {"foo ,bar, baz ", ',', 4, 3}, + {"foo ,bar, baz ", ',', 4, 3}, + {"00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01", '-', 4, 4}, +}; +} // namespace + +// Test fixture +class SplitStringTestFixture : public ::testing::TestWithParam +{}; + +TEST_P(SplitStringTestFixture, SplitsAsExpected) +{ + const SplitStringTestData test_param = GetParam(); + std::vector fields(test_param.expected_number_strings); + size_t got_splits_num = opentelemetry::trace::propagation::detail::SplitString( + test_param.input, test_param.separator, fields.data(), test_param.max_count); + + // Assert on the output + EXPECT_EQ(got_splits_num, test_param.expected_number_strings); +} + +INSTANTIATE_TEST_SUITE_P(SplitStringTestCases, + SplitStringTestFixture, + ::testing::ValuesIn(split_string_test_cases)); diff --git a/deps/opentelemetry-cpp/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/deps/opentelemetry-cpp/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index af4ccb16efb..9baf9ef7bde 100644 --- a/deps/opentelemetry-cpp/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/deps/opentelemetry-cpp/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -28,20 +28,18 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable { private: /** - * A helper method that writes a key/value pair under a specified name, the two names used here - * being "attributes" and "resources" + * A helper method that writes a value under a specified name. + * `name` will be at the root of the JSON object. If it has to be nested under some other keys, + * then write `name` as `key1.key2.[...].name` */ - void WriteKeyValue(nostd::string_view key, - const opentelemetry::common::AttributeValue &value, - const std::string &name); - - void WriteKeyValue(nostd::string_view key, - const opentelemetry::sdk::common::OwnedAttributeValue &value, - const std::string &name); + void WriteValue(const opentelemetry::sdk::common::OwnedAttributeValue &value, + const std::string &name); void WriteValue(const opentelemetry::common::AttributeValue &value, const std::string &name); public: + ElasticSearchRecordable() noexcept; + /** * Returns a JSON object contain the log information */ diff --git a/deps/opentelemetry-cpp/exporters/elasticsearch/src/es_log_record_exporter.cc b/deps/opentelemetry-cpp/exporters/elasticsearch/src/es_log_record_exporter.cc index f464df5006f..1ec786a198f 100644 --- a/deps/opentelemetry-cpp/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/deps/opentelemetry-cpp/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -288,7 +288,12 @@ class AsyncResponseHandler : public http_client::EventHandler #endif ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter() - : options_{ElasticsearchExporterOptions()}, + : ElasticsearchLogRecordExporter(ElasticsearchExporterOptions()) +{} + +ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter( + const ElasticsearchExporterOptions &options) + : options_{options}, http_client_{ext::http::client::HttpClientFactory::Create()} #ifdef ENABLE_ASYNC_EXPORT , @@ -301,11 +306,6 @@ ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter() #endif } -ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter( - const ElasticsearchExporterOptions &options) - : options_{options}, http_client_{ext::http::client::HttpClientFactory::Create()} -{} - std::unique_ptr ElasticsearchLogRecordExporter::MakeRecordable() noexcept { return std::unique_ptr(new ElasticSearchRecordable()); diff --git a/deps/opentelemetry-cpp/exporters/elasticsearch/src/es_log_recordable.cc b/deps/opentelemetry-cpp/exporters/elasticsearch/src/es_log_recordable.cc index 663691273b8..3412a8cc611 100644 --- a/deps/opentelemetry-cpp/exporters/elasticsearch/src/es_log_recordable.cc +++ b/deps/opentelemetry-cpp/exporters/elasticsearch/src/es_log_recordable.cc @@ -14,44 +14,7 @@ namespace exporter { namespace logs { -void ElasticSearchRecordable::WriteKeyValue(nostd::string_view key, - const opentelemetry::common::AttributeValue &value, - const std::string &name) -{ - switch (value.index()) - { - case common::AttributeType::kTypeBool: - json_[name][key.data()] = opentelemetry::nostd::get(value) ? true : false; - return; - case common::AttributeType::kTypeInt: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeInt64: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeUInt: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeUInt64: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeDouble: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeCString: - json_[name][key.data()] = opentelemetry::nostd::get(value); - return; - case common::AttributeType::kTypeString: - json_[name][key.data()] = - opentelemetry::nostd::get(value).data(); - return; - default: - return; - } -} - -void ElasticSearchRecordable::WriteKeyValue( - nostd::string_view key, +void ElasticSearchRecordable::WriteValue( const opentelemetry::sdk::common::OwnedAttributeValue &value, const std::string &name) { @@ -59,25 +22,25 @@ void ElasticSearchRecordable::WriteKeyValue( switch (value.index()) { case common::kTypeBool: - json_[name][key.data()] = opentelemetry::nostd::get(value) ? true : false; + json_[name] = opentelemetry::nostd::get(value) ? true : false; return; case common::kTypeInt: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeInt64: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeUInt: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeUInt64: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeDouble: - json_[name][key.data()] = opentelemetry::nostd::get(value); + json_[name] = opentelemetry::nostd::get(value); return; case common::kTypeString: - json_[name][key.data()] = opentelemetry::nostd::get(value).data(); + json_[name] = opentelemetry::nostd::get(value).data(); return; default: return; @@ -197,6 +160,11 @@ void ElasticSearchRecordable::WriteValue(const opentelemetry::common::AttributeV } } +ElasticSearchRecordable::ElasticSearchRecordable() noexcept : sdk::logs::Recordable() +{ + json_["ecs"]["version"] = "8.11.0"; +} + nlohmann::json ElasticSearchRecordable::GetJSON() noexcept { return json_; @@ -205,7 +173,38 @@ nlohmann::json ElasticSearchRecordable::GetJSON() noexcept void ElasticSearchRecordable::SetTimestamp( opentelemetry::common::SystemTimestamp timestamp) noexcept { - json_["timestamp"] = timestamp.time_since_epoch().count(); + const std::chrono::system_clock::time_point timePoint{timestamp}; + + // If built with with at least cpp 20 then use std::format + // Otherwise use the old style to format the timestamp in UTC +#if __cplusplus >= 202002L + const std::string dateStr = std::format("{:%FT%T%Ez}", timePoint); +#else + const static int dateToSecondsSize = 19; + const static int millisecondsSize = 8; + const static int timeZoneSize = 1; + const static int dateSize = dateToSecondsSize + millisecondsSize + timeZoneSize; + + std::time_t time = std::chrono::system_clock::to_time_t(timePoint); + std::tm tm = *std::gmtime(&time); + + char bufferDate[dateSize]; // example: 2024-10-18T07:26:00.123456Z + std::strftime(bufferDate, sizeof(bufferDate), "%Y-%m-%dT%H:%M:%S", &tm); + auto microseconds = + std::chrono::duration_cast(timePoint.time_since_epoch()) % + std::chrono::seconds(1); + + char bufferMilliseconds[millisecondsSize]; + std::snprintf(bufferMilliseconds, sizeof(bufferMilliseconds), ".%06ld", + static_cast(microseconds.count())); + + std::strcat(bufferDate, bufferMilliseconds); + std::strcat(bufferDate, "Z"); + + const std::string dateStr(bufferDate); +#endif + + json_["@timestamp"] = dateStr; } void ElasticSearchRecordable::SetObservedTimestamp( @@ -216,23 +215,25 @@ void ElasticSearchRecordable::SetObservedTimestamp( void ElasticSearchRecordable::SetSeverity(opentelemetry::logs::Severity severity) noexcept { + auto &severityField = json_["log"]["level"]; + // Convert the severity enum to a string std::uint32_t severity_index = static_cast(severity); if (severity_index >= std::extent::value) { std::stringstream sout; sout << "Invalid severity(" << severity_index << ")"; - json_["severity"] = sout.str(); + severityField = sout.str(); } else { - json_["severity"] = opentelemetry::logs::SeverityNumToText[severity_index]; + severityField = opentelemetry::logs::SeverityNumToText[severity_index]; } } void ElasticSearchRecordable::SetBody(const opentelemetry::common::AttributeValue &message) noexcept { - WriteValue(message, "body"); + WriteValue(message, "message"); } void ElasticSearchRecordable::SetTraceId(const opentelemetry::trace::TraceId &trace_id) noexcept @@ -275,7 +276,7 @@ void ElasticSearchRecordable::SetAttribute( nostd::string_view key, const opentelemetry::common::AttributeValue &value) noexcept { - WriteKeyValue(key, value, "attributes"); + WriteValue(value, key.data()); } void ElasticSearchRecordable::SetResource( @@ -283,7 +284,7 @@ void ElasticSearchRecordable::SetResource( { for (auto &attribute : resource.GetAttributes()) { - WriteKeyValue(attribute.first, attribute.second, "resource"); + WriteValue(attribute.second, attribute.first); } } @@ -291,7 +292,7 @@ void ElasticSearchRecordable::SetInstrumentationScope( const opentelemetry::sdk::instrumentationscope::InstrumentationScope &instrumentation_scope) noexcept { - json_["name"] = instrumentation_scope.GetName(); + json_["log"]["logger"] = instrumentation_scope.GetName(); } } // namespace logs diff --git a/deps/opentelemetry-cpp/exporters/elasticsearch/test/es_log_record_exporter_test.cc b/deps/opentelemetry-cpp/exporters/elasticsearch/test/es_log_record_exporter_test.cc index 8a1c81da48d..6bdd5248a56 100644 --- a/deps/opentelemetry-cpp/exporters/elasticsearch/test/es_log_record_exporter_test.cc +++ b/deps/opentelemetry-cpp/exporters/elasticsearch/test/es_log_record_exporter_test.cc @@ -2,50 +2,48 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/exporters/elasticsearch/es_log_record_exporter.h" -#include "opentelemetry/ext/http/server/http_server.h" -#include "opentelemetry/logs/provider.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/exporters/elasticsearch/es_log_recordable.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/logs/simple_log_record_processor.h" +#include "opentelemetry/sdk/resource/resource.h" #include -#include +#include +#include namespace sdklogs = opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; namespace nostd = opentelemetry::nostd; namespace logs_exporter = opentelemetry::exporter::logs; -TEST(ElasticsearchLogsExporterTests, Dummy) -{ - // to enable linking -} - -#if 0 // Attempt to write a log to an invalid host/port, test that the Export() returns failure -TEST(ElasticsearchLogsExporterTests, InvalidEndpoint) +TEST(DISABLED_ElasticsearchLogsExporterTests, InvalidEndpoint) { // Create invalid connection options for the elasticsearch exporter logs_exporter::ElasticsearchExporterOptions options("localhost", -1); // Create an elasticsearch exporter - auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter(options)); + auto exporter = std::unique_ptr( + new logs_exporter::ElasticsearchLogRecordExporter(options)); // Create a log record and send to the exporter auto record = exporter->MakeRecordable(); auto result = exporter->Export(nostd::span>(&record, 1)); // Ensure the return value is failure - ASSERT_EQ(result, sdk::common::ExportResult::kFailure); + ASSERT_EQ(result, opentelemetry::sdk::common::ExportResult::kFailure); } // Test that when the exporter is shutdown, any call to Export should return failure -TEST(ElasticsearchLogsExporterTests, Shutdown) +TEST(DISABLED_ElasticsearchLogsExporterTests, Shutdown) { // Create an elasticsearch exporter and immediately shut it down - auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter); + auto exporter = std::unique_ptr( + new logs_exporter::ElasticsearchLogRecordExporter); bool shutdownResult = exporter->Shutdown(); ASSERT_TRUE(shutdownResult); @@ -54,15 +52,15 @@ TEST(ElasticsearchLogsExporterTests, Shutdown) auto result = exporter->Export(nostd::span>(&record, 1)); // Ensure the return value is failure - ASSERT_EQ(result, sdk::common::ExportResult::kFailure); + ASSERT_EQ(result, opentelemetry::sdk::common::ExportResult::kFailure); } // Test the elasticsearch recordable object -TEST(ElasticsearchLogsExporterTests, RecordableCreation) +TEST(DISABLED_ElasticsearchLogsExporterTests, RecordableCreation) { // Create an elasticsearch exporter - auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter); + auto exporter = std::unique_ptr( + new logs_exporter::ElasticsearchLogRecordExporter); // Create a recordable auto record = exporter->MakeRecordable(); @@ -79,4 +77,52 @@ TEST(ElasticsearchLogsExporterTests, RecordableCreation) exporter->Export(nostd::span>(&record, 1)); } -#endif + +TEST(ElasticsearchLogRecordableTests, BasicTests) +{ + const auto severity = logs_api::Severity::kFatal; + const std::array stringlist{ + {nostd::string_view("string1"), nostd::string_view("string2")}}; + + const std::int64_t expected_observed_ts = 1732063944999647774LL; + const std::string expected_timestamp("2024-11-20T00:52:24.999647Z"); + const std::string expected_severity( + opentelemetry::logs::SeverityNumToText[static_cast(severity)]); + const std::string expected_body("Body of the log message"); + const std::string expected_scope_name("scope_name"); + const bool expected_boolean = false; + const int expected_int = 1; + const double expected_double = 2.0; + + const nlohmann::json expected{ + {"@timestamp", expected_timestamp}, + {"boolean", expected_boolean}, + {"double", expected_double}, + {"ecs", {{"version", "8.11.0"}}}, + {"int", expected_int}, + {"log", {{"level", expected_severity}, {"logger", expected_scope_name}}}, + {"message", expected_body}, + {"observedtimestamp", expected_observed_ts}, + {"stringlist", {stringlist[0], stringlist[1]}}}; + + const opentelemetry::common::SystemTimestamp now{std::chrono::nanoseconds(expected_observed_ts)}; + + const auto scope = + opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create(expected_scope_name); + + opentelemetry::exporter::logs::ElasticSearchRecordable recordable; + recordable.SetTimestamp(now); + recordable.SetObservedTimestamp(now); + recordable.SetSeverity(severity); + recordable.SetBody(expected_body); + recordable.SetInstrumentationScope(*scope); + + recordable.SetAttribute("boolean", expected_boolean); + recordable.SetAttribute("int", expected_int); + recordable.SetAttribute("double", expected_double); + recordable.SetAttribute("stringlist", stringlist); + + const auto actual = recordable.GetJSON(); + + EXPECT_EQ(actual, expected); +} diff --git a/deps/opentelemetry-cpp/exporters/etw/README.md b/deps/opentelemetry-cpp/exporters/etw/README.md index 3339223fa6c..372aa5738e7 100644 --- a/deps/opentelemetry-cpp/exporters/etw/README.md +++ b/deps/opentelemetry-cpp/exporters/etw/README.md @@ -12,215 +12,5 @@ subsequent data recording or forwarding to alternate pipelines and flows. Windows Event Tracing infrastructure is available to any vendor or application being deployed on Windows. -## API support - -These are the features planned to be supported by ETW exporter: - -- [x] OpenTelemetry Tracing API and SDK headers are **stable** and moving - towards GA. -- [ ] OpenTelemetry Logging API is work-in-progress, pending implementation of - [Latest Logging API spec - here](https://github.com/open-telemetry/oteps/pull/150) -- [ ] OpenTelemetry Metrics API is not implemented yet. - -Implementation of OpenTelemetry C++ SDK ETW exporter on Windows OS is `header -only` : - -- full definitions of all macros, functions and classes comprising the library -are visible to the compiler in a header file form. -- implementation does not need to be separately compiled, packaged and installed - in order to be used. - -All that is required is to point the compiler at the location of the headers, -and then `#include` the header files into the application source. Compiler's -optimizer can do a much better job when all the library's source code is -available. Several options below may be turned on to optimize the code with the -usage of standard C++ library, Microsoft Guidelines Support library, Google -Abseil Variant library. Or enabling support for non-standard features, such as -8-bit byte arrays support that enables performance-efficient representation of -binary blobs on ETW wire. - -## Example project - -The following include directories are required, relative to the top-level source -tree of OpenTelemetry C++ repo: - -- api/include/ -- exporters/etw/include/ -- sdk/include/ - -Code that instantiates ETW TracerProvider, subsequently obtaining a Tracer bound -to `OpenTelemetry-ETW-Provider`, and emitting a span named `MySpan` with -attributes on it, as well as `MyEvent` within that span. - -```cpp - -#include -#include - -#include "opentelemetry/exporters/etw/etw_tracer_exporter.h" - -using namespace OPENTELEMETRY_NAMESPACE; -using namespace opentelemetry::exporter::etw; - -// Supply unique instrumentation name (ETW Provider Name) here: -std::string providerName = "OpenTelemetry-ETW-Provider"; - -exporter::etw::TracerProvider tp; - -int main(int argc, const char* argv[]) -{ - // Obtain a Tracer object for instrumentation name. - // Each Tracer is associated with unique TraceId. - auto tracer = tp.GetTracer(providerName, "TLD"); - - // Properties is a helper class in ETW namespace that is otherwise compatible - // with Key-Value Iterable accepted by OpenTelemetry API. Using Properties - // should enable more efficient data transfer without unnecessary memcpy. - - // Span attributes - Properties attribs = - { - {"attrib1", 1}, - {"attrib2", 2} - }; - - // Start Span with attributes - auto span = tracer->StartSpan("MySpan", attribs); - - // Emit an event on Span - std::string eventName = "MyEvent1"; - Properties event = - { - {"uint32Key", (uint32_t)1234}, - {"uint64Key", (uint64_t)1234567890}, - {"strKey", "someValue"} - }; - span->AddEvent(eventName, event); - - // End Span. - span->End(); - - // Close the Tracer on application stop. - tracer->CloseWithMicroseconds(0); - - return 0; -} -``` - -Note that different `Tracer` objects may be bound to different ETW destinations. - -## Build options and Compiler Defines - -While including OpenTelemetry C++ SDK with ETW exporter, the customers are in -complete control of what options they would like to enable for their project -using `Preprocessor Definitions`. - -These options affect how "embedded in application" OpenTelemetry C++ SDK code is -compiled: - -| Name | Description | -|---------------------|------------------------------------------------------------------------------------------------------------------------| -| OPENTELEMETRY_STL_VERSION | Use STL classes for API surface. C++20 is recommended. Some customers may benefit from STL library provided with the compiler instead of using custom OpenTelemetry `nostd::` implementation due to security and performance considerations. | -| HAVE_GSL | Use [Microsoft GSL](https://github.com/microsoft/GSL) for `gsl::span` implementation. Library must be in include path. Microsoft GSL claims to be the most feature-complete implementation of `std::span`. It may be used instead of `nostd::span` implementation in projects that statically link OpenTelemetry SDK. | -| HAVE_TLD | Use ETW/TraceLogging Dynamic protocol. This is the default implementation compatible with existing C# "listeners" / "decoders" of ETW events. This option requires an additional optional Microsoft MIT-licensed `TraceLoggingDynamic.h` header. | - -## Debugging - -### ETW TraceLogging Dynamic Events - -ETW supports a mode that is called "Dynamic Manifest", where event may contain -strongly-typed key-value pairs, with primitive types such as `integer`, -`double`, `string`, etc. This mode requires `TraceLoggingDynamic.h` header. -Please refer to upstream repository containining [Microsoft TraceLogging Dynamic -framework](https://github.com/microsoft/tracelogging-dynamic-windows) licensed -under [MIT -License](https://github.com/microsoft/tracelogging-dynamic-windows/blob/main/LICENSE). - -Complete [list of ETW -types](https://docs.microsoft.com/en-us/windows/win32/wes/eventmanifestschema-outputtype-complextype#remarks). - -OpenTelemetry C++ ETW exporter implements the following type mapping: - -| OpenTelemetry C++ API type | ETW type | -|----------------------------|-----------------| -| bool | xs:byte | -| int (32-bit) | xs:int | -| int (64-bit) | xs:long | -| uint (32-bit) | xs:unsignedInt | -| uint (64-bit) | xs:unsignedLong | -| double | xs:double | -| string | win:Utf8 | - -Support for arrays of primitive types is not implemented yet. - -Visual Studio 2019 allows to use `View -> Other Windows -> Diagnostic Events` to -capture events that are emitted by instrumented application and sent to ETW -provider in a live view. Instrumentation name passed to `GetTracer` API above -corresponds to `ETW Provider Name`. If Instrumentation name contains a GUID - -starts with a curly brace, e.g. `{deadbeef-fade-dead-c0de-cafebabefeed}` then -the parameter is assumed to be `ETW Provider GUID`. - -Click on `Settings` and add the provider to monitor either by its Name or by -GUID. In above example, the provider name is `OpenTelemetry-ETW-Provider`. -Please refer to Diagnostic Events usage instructions -[here](https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-diagnostics-how-to-monitor-and-diagnose-services-locally#view-service-fabric-system-events-in-visual-studio) -to learn more. Note that running ETW Listener in Visual Studio requires -Elevation, i.e. Visual Studio would prompt you to confirm that you accept to run -the ETW Listener process as Administrator. This is a limitation of ETW -Listeners, they must be run as privileged process. - -### ETW events encoded in MessagePack - -OpenTelemetry ETW exporter optionally allows to encode the incoming event -payload using [MessagePack](https://msgpack.org/index.html) compact binary -protocol. ETW/MsgPack encoding requires -[nlohmann/json](https://github.com/nlohmann/json) library to be included in the -build of OpenTelemetry ETW exporter. Any recent version of `nlohmann/json` is -compatible with ETW exporter. For example, the version included in -`third_party/nlohmann-json` directory may be used. - -There is currently **no built-in decoder available** for this format. However, -there is ongoing effort to include the ETW/MsgPack decoder in -[Azure/diagnostics-eventflow](https://github.com/Azure/diagnostics-eventflow) -project, which may be used as a side-car listener to forward incoming -ETW/MsgPack events to many other destinations, such as: - -- StdOutput (console output) -- HTTP (json via http) -- Application Insights -- Azure EventHub -- Elasticsearch -- Azure Monitor Logs - -And community-contributed exporters: - -- Google Big Query output -- SQL Server output -- ReflectInsight output -- Splunk output - -[This PR](https://github.com/Azure/diagnostics-eventflow/pull/382) implements -the `Input adapter` for OpenTelemetry ETW/MsgPack protocol encoded events for -Azure EventFlow. - -Other standard tools for processing ETW events on Windows OS, such as: - -- [PerfView](https://github.com/microsoft/perfview) -- [PerfViewJS](https://github.com/microsoft/perfview/tree/main/src/PerfViewJS) - -will be augmented in future with support for ETW/MsgPack encoding. - -## Addendum - -This document needs to be supplemented with additional information: - -- [ ] mapping between OpenTelemetry fields and concepts and their corresponding - ETW counterparts -- [ ] links to E2E instrumentation example and ETW listener -- [ ] Logging API example -- [ ] Metrics API example (once Metrics spec is finalized) -- [ ] example how ETW Listener may employ OpenTelemetry .NET SDK to 1-1 - transform from ETW events back to OpenTelemetry flow -- [ ] links to NuGet package that contains the source code of SDK that includes - OpenTelemetry SDK and ETW exporter +It is recommended to consume this exporter via +[vcpkg](https://vcpkg.io/en/package/opentelemetry-cpp). diff --git a/deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_data.cc b/deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_data.cc index 2a77e0b5a36..90f1c1450fa 100644 --- a/deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_data.cc +++ b/deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_data.cc @@ -31,7 +31,9 @@ void SimpleAggregateInMemoryMetricData::Add(std::unique_ptr res const auto &metric = m.instrument_descriptor.name_; for (const auto &pda : m.point_data_attr_) { - data_[{scope, metric}].insert({pda.attributes, pda.point_data}); + // NOTE: Explicit type conversion added for C++11 (gcc 4.8) + data_[std::tuple{scope, metric}].insert( + {pda.attributes, pda.point_data}); } } } @@ -41,7 +43,8 @@ const SimpleAggregateInMemoryMetricData::AttributeToPoint &SimpleAggregateInMemo const std::string &scope, const std::string &metric) { - return data_[{scope, metric}]; + // NOTE: Explicit type conversion added for C++11 (gcc 4.8) + return data_[std::tuple{scope, metric}]; } void SimpleAggregateInMemoryMetricData::Clear() diff --git a/deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_exporter_factory.cc b/deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_exporter_factory.cc index f2577c4e9b7..0deff73dcd6 100644 --- a/deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_exporter_factory.cc +++ b/deps/opentelemetry-cpp/exporters/memory/src/in_memory_metric_exporter_factory.cc @@ -49,7 +49,7 @@ class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter OTEL_INTERNAL_LOG_ERROR("[In Memory Metric Exporter] Exporting failed, exporter is shutdown"); return ExportResult::kFailure; } - data_->Add(std::make_unique(data)); + data_->Add(std::unique_ptr(new ResourceMetrics{data})); return ExportResult::kSuccess; } @@ -78,14 +78,15 @@ class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter std::unique_ptr InMemoryMetricExporterFactory::Create( const std::shared_ptr &data) { - return Create(data, [](auto) { return AggregationTemporality::kCumulative; }); + return Create(data, + [](sdk::metrics::InstrumentType) { return AggregationTemporality::kCumulative; }); } std::unique_ptr InMemoryMetricExporterFactory::Create( const std::shared_ptr &data, const AggregationTemporalitySelector &temporality) { - return std::make_unique(data, temporality); + return std::unique_ptr(new InMemoryMetricExporter{data, temporality}); } } // namespace memory diff --git a/deps/opentelemetry-cpp/exporters/memory/test/in_memory_metric_data_test.cc b/deps/opentelemetry-cpp/exporters/memory/test/in_memory_metric_data_test.cc index ffaba2cfb9c..3f2d661759e 100644 --- a/deps/opentelemetry-cpp/exporters/memory/test/in_memory_metric_data_test.cc +++ b/deps/opentelemetry-cpp/exporters/memory/test/in_memory_metric_data_test.cc @@ -23,8 +23,8 @@ TEST(InMemoryMetricDataTest, CircularBuffer) { CircularBufferInMemoryMetricData buf(10); Resource resource = Resource::GetEmpty(); - buf.Add(std::make_unique( - &resource, std::vector{{nullptr, std::vector{}}})); + buf.Add(std::unique_ptr(new ResourceMetrics{ + &resource, std::vector{{nullptr, std::vector{}}}})); EXPECT_EQ((*buf.Get().begin())->resource_, &resource); } @@ -45,8 +45,8 @@ TEST(InMemoryMetricDataTest, SimpleAggregate) md.instrument_descriptor.name_ = "my-metric"; md.point_data_attr_.push_back(pda); - agg.Add(std::make_unique( - &resource, std::vector{{scope.get(), std::vector{md}}})); + agg.Add(std::unique_ptr(new ResourceMetrics{ + &resource, std::vector{{scope.get(), std::vector{md}}}})); auto it = agg.Get("my-scope", "my-metric").begin(); auto saved_point = opentelemetry::nostd::get(it->second); diff --git a/deps/opentelemetry-cpp/exporters/otlp/BUILD b/deps/opentelemetry-cpp/exporters/otlp/BUILD index a2dd8f8c650..eb3d23d5791 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/BUILD +++ b/deps/opentelemetry-cpp/exporters/otlp/BUILD @@ -42,11 +42,13 @@ cc_library( name = "otlp_grpc_client", srcs = [ "src/otlp_grpc_client.cc", + "src/otlp_grpc_client_factory.cc", "src/otlp_grpc_utils.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", "include/opentelemetry/exporters/otlp/otlp_grpc_client.h", + "include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h", "include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h", "include/opentelemetry/exporters/otlp/otlp_grpc_utils.h", "include/opentelemetry/exporters/otlp/protobuf_include_prefix.h", diff --git a/deps/opentelemetry-cpp/exporters/otlp/CMakeLists.txt b/deps/opentelemetry-cpp/exporters/otlp/CMakeLists.txt index 83b35f16a78..34da75b563a 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/CMakeLists.txt +++ b/deps/opentelemetry-cpp/exporters/otlp/CMakeLists.txt @@ -23,8 +23,10 @@ target_link_libraries(opentelemetry_otlp_recordable if(WITH_OTLP_GRPC) find_package(gRPC REQUIRED) - add_library(opentelemetry_exporter_otlp_grpc_client src/otlp_grpc_client.cc - src/otlp_grpc_utils.cc) + add_library( + opentelemetry_exporter_otlp_grpc_client + src/otlp_grpc_client.cc src/otlp_grpc_client_factory.cc + src/otlp_grpc_utils.cc) set_target_properties(opentelemetry_exporter_otlp_grpc_client PROPERTIES EXPORT_NAME otlp_grpc_client) set_target_version(opentelemetry_exporter_otlp_grpc_client) @@ -45,7 +47,7 @@ if(WITH_OTLP_GRPC) INTERFACE_INCLUDE_DIRECTORIES) if(GRPC_INCLUDE_DIRECTORY) target_include_directories( - opentelemetry_exporter_otlp_grpc_client + opentelemetry_exporter_otlp_grpc_client BEFORE PUBLIC "$") endif() target_include_directories( diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h index 89224403a44..3ded3a16ebf 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h @@ -13,14 +13,18 @@ #include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on #include "google/protobuf/arena.h" #include "opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h" #include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" #include "opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -28,11 +32,25 @@ namespace exporter namespace otlp { +class OtlpGrpcClient; struct OtlpGrpcClientOptions; - -#ifdef ENABLE_ASYNC_EXPORT struct OtlpGrpcClientAsyncData; -#endif + +class OtlpGrpcClientReferenceGuard +{ +public: + OtlpGrpcClientReferenceGuard() noexcept; + ~OtlpGrpcClientReferenceGuard() noexcept; + + OtlpGrpcClientReferenceGuard(const OtlpGrpcClientReferenceGuard &) = delete; + OtlpGrpcClientReferenceGuard(OtlpGrpcClientReferenceGuard &&) = delete; + OtlpGrpcClientReferenceGuard &operator=(const OtlpGrpcClientReferenceGuard &) = delete; + OtlpGrpcClientReferenceGuard &operator=(OtlpGrpcClientReferenceGuard &&) = delete; + +private: + friend class OtlpGrpcClient; + std::atomic has_value_; +}; /** * The OTLP gRPC client contains utility functions of gRPC. @@ -40,7 +58,7 @@ struct OtlpGrpcClientAsyncData; class OtlpGrpcClient { public: - OtlpGrpcClient(); + OtlpGrpcClient(const OtlpGrpcClientOptions &options); ~OtlpGrpcClient(); @@ -58,20 +76,18 @@ class OtlpGrpcClient /** * Create trace service stub to communicate with the OpenTelemetry Collector. */ - static std::unique_ptr - MakeTraceServiceStub(const OtlpGrpcClientOptions &options); + std::unique_ptr MakeTraceServiceStub(); /** * Create metrics service stub to communicate with the OpenTelemetry Collector. */ - static std::unique_ptr - MakeMetricsServiceStub(const OtlpGrpcClientOptions &options); + std::unique_ptr + MakeMetricsServiceStub(); /** * Create logs service stub to communicate with the OpenTelemetry Collector. */ - static std::unique_ptr - MakeLogsServiceStub(const OtlpGrpcClientOptions &options); + std::unique_ptr MakeLogsServiceStub(); static grpc::Status DelegateExport( proto::collector::trace::v1::TraceService::StubInterface *stub, @@ -94,8 +110,18 @@ class OtlpGrpcClient proto::collector::logs::v1::ExportLogsServiceRequest &&request, proto::collector::logs::v1::ExportLogsServiceResponse *response); -#ifdef ENABLE_ASYNC_EXPORT + void AddReference(OtlpGrpcClientReferenceGuard &guard, + const OtlpGrpcClientOptions &options) noexcept; + /** + * Reomve reference fro a guard object + * + * @param guard guard object to remove reference from + * @return true if there is no more reference to this gRPC client + */ + bool RemoveReference(OtlpGrpcClientReferenceGuard &guard) noexcept; + +#ifdef ENABLE_ASYNC_EXPORT /** * Async export * @param options Options used to message to create gRPC context and stub(if necessary) @@ -155,6 +181,7 @@ class OtlpGrpcClient const proto::collector::logs::v1::ExportLogsServiceRequest &, proto::collector::logs::v1::ExportLogsServiceResponse *)> &&result_callback) noexcept; +#endif /** * Force flush the gRPC client. @@ -167,17 +194,19 @@ class OtlpGrpcClient * timeout is applied. * @return return the status of this operation */ - bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept; + bool Shutdown(OtlpGrpcClientReferenceGuard &guard, + std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept; std::shared_ptr MutableAsyncData(const OtlpGrpcClientOptions &options); + bool IsShutdown() const noexcept; + private: // Stores if this gRPC client had its Shutdown() method called std::atomic is_shutdown_; // Stores shared data between threads of this gRPC client std::shared_ptr async_data_; -#endif }; } // namespace otlp } // namespace exporter diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h new file mode 100644 index 00000000000..ded0eadd8e2 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h" +#include "opentelemetry/nostd/shared_ptr.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OtlpGrpcClientReferenceGuard; +class OtlpGrpcClient; + +/** + * Factory class for OtlpGrpcClient. + */ +class OPENTELEMETRY_EXPORT OtlpGrpcClientFactory +{ +public: + /** + * Create an OtlpGrpcClient using all default options. + */ + static std::shared_ptr Create(const OtlpGrpcClientOptions &options); + + static std::shared_ptr CreateReferenceGuard(); +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h index 80346a253da..1022b0dc8fc 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h @@ -6,12 +6,17 @@ #include #include +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on #include "opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format on +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/exporters/otlp/otlp_environment.h" @@ -23,6 +28,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClientReferenceGuard; + class OtlpGrpcClient; /** @@ -36,11 +43,22 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter */ OtlpGrpcExporter(); + /** + * Create an OtlpGrpcExporter using specified OtlpGrpcClient. + * + * @param options options to create exporter + * @param client the gRPC client to use + */ + OtlpGrpcExporter(const OtlpGrpcExporterOptions &options, + const std::shared_ptr &client); + /** * Create an OtlpGrpcExporter using the given options. */ explicit OtlpGrpcExporter(const OtlpGrpcExporterOptions &options); + ~OtlpGrpcExporter() override; + /** * Create a span recordable. * @return a newly initialized Recordable object @@ -71,20 +89,26 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; + /** + * Get the Client object + * + * @return return binded gRPC client + */ + const std::shared_ptr &GetClient() const noexcept; + private: // The configuration options associated with this exporter. const OtlpGrpcExporterOptions options_; -#ifdef ENABLE_ASYNC_EXPORT std::shared_ptr client_; -#endif + std::shared_ptr client_reference_guard_; // For testing friend class OtlpGrpcExporterTestPeer; friend class OtlpGrpcLogRecordExporterTestPeer; // Store service stub internally. Useful for testing. - std::unique_ptr trace_service_stub_; + std::shared_ptr trace_service_stub_; /** * Create an OtlpGrpcExporter using the specified service stub. @@ -92,6 +116,16 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter * @param stub the service stub to be used for exporting */ OtlpGrpcExporter(std::unique_ptr stub); + + /** + * Create an OtlpGrpcExporter using the specified service stub and gRPC client. + * Only tests can call this constructor directly. + * @param stub the service stub to be used for exporting + * @param client the gRPC client to use + */ + OtlpGrpcExporter(std::unique_ptr stub, + const std::shared_ptr &client); + std::atomic is_shutdown_{false}; bool isShutdown() const noexcept; }; diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h index 518cf8b82cb..24d19d5ced4 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h @@ -6,6 +6,7 @@ #include #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/trace/exporter.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,6 +15,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClient; + /** * Factory class for OtlpGrpcExporter. */ @@ -30,6 +33,13 @@ class OPENTELEMETRY_EXPORT OtlpGrpcExporterFactory */ static std::unique_ptr Create( const OtlpGrpcExporterOptions &options); + + /** + * Create an OtlpGrpcExporter using the given options and gRPC client. + */ + static std::unique_ptr Create( + const OtlpGrpcExporterOptions &options, + const std::shared_ptr &client); }; } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h index 72af90701f2..da278ccd282 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h @@ -4,15 +4,18 @@ #pragma once // clang-format off - #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on + #include "opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // clang-format on #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/logs/exporter.h" #include @@ -23,6 +26,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClientReferenceGuard; + class OtlpGrpcClient; /** @@ -36,12 +41,23 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo */ OtlpGrpcLogRecordExporter(); + /** + * Create an OtlpGrpcLogRecordExporter using specified OtlpGrpcClient. + * + * @param options options to create exporter + * @param client the gRPC client to use + */ + OtlpGrpcLogRecordExporter(const OtlpGrpcLogRecordExporterOptions &options, + const std::shared_ptr &client); + /** * Create an OtlpGrpcLogRecordExporter with user specified options. * @param options An object containing the user's configuration options. */ OtlpGrpcLogRecordExporter(const OtlpGrpcLogRecordExporterOptions &options); + ~OtlpGrpcLogRecordExporter() override; + /** * Creates a recordable that stores the data in protobuf. * @return a newly initialized Recordable object. @@ -72,19 +88,25 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; + /** + * Get the Client object + * + * @return return binded gRPC client + */ + const std::shared_ptr &GetClient() const noexcept; + private: // Configuration options for the exporter const OtlpGrpcLogRecordExporterOptions options_; -#ifdef ENABLE_ASYNC_EXPORT std::shared_ptr client_; -#endif + std::shared_ptr client_reference_guard_; // For testing friend class OtlpGrpcLogRecordExporterTestPeer; // Store service stub internally. Useful for testing. - std::unique_ptr log_service_stub_; + std::shared_ptr log_service_stub_; /** * Create an OtlpGrpcLogRecordExporter using the specified service stub. @@ -93,6 +115,17 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo */ OtlpGrpcLogRecordExporter( std::unique_ptr stub); + + /** + * Create an OtlpGrpcLogRecordExporter using the specified service stub and gRPC client. + * Only tests can call this constructor directly. + * @param stub the service stub to be used for exporting + * @param client the gRPC client to use + */ + OtlpGrpcLogRecordExporter( + std::unique_ptr stub, + const std::shared_ptr &client); + std::atomic is_shutdown_{false}; bool isShutdown() const noexcept; }; diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h index 7a886159594..e69a20b4522 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h @@ -4,6 +4,7 @@ #pragma once #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/logs/exporter.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,6 +13,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClient; + /** * Factory class for OtlpGrpcLogRecordExporter. */ @@ -24,10 +27,17 @@ class OPENTELEMETRY_EXPORT OtlpGrpcLogRecordExporterFactory static std::unique_ptr Create(); /** - * Create a OtlpGrpcLogRecordExporter. + * Create a OtlpGrpcLogRecordExporter using the given options. */ static std::unique_ptr Create( const OtlpGrpcLogRecordExporterOptions &options); + + /** + * Create a OtlpGrpcLogRecordExporter using the given options and gRPC client. + */ + static std::unique_ptr Create( + const OtlpGrpcLogRecordExporterOptions &options, + const std::shared_ptr &client); }; } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h index 3899e926f64..d3d857b3f08 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h @@ -4,15 +4,18 @@ #pragma once // clang-format off - #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on + #include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // clang-format on #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include @@ -23,6 +26,7 @@ namespace exporter namespace otlp { +class OtlpGrpcClientReferenceGuard; class OtlpGrpcClient; /** @@ -36,11 +40,22 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp */ OtlpGrpcMetricExporter(); + /** + * Create an OtlpGrpcMetricExporter using specified OtlpGrpcClient. + * + * @param options options to create exporter + * @param client the gRPC client to use + */ + OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options, + const std::shared_ptr &client); + /** * Create an OtlpGrpcMetricExporter using the given options. */ explicit OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options); + ~OtlpGrpcMetricExporter() override; + /** * Get the AggregationTemporality for exporter * @@ -58,13 +73,19 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; + /** + * Get the Client object + * + * @return return binded gRPC client + */ + const std::shared_ptr &GetClient() const noexcept; + private: // The configuration options associated with this exporter. const OtlpGrpcMetricExporterOptions options_; -#ifdef ENABLE_ASYNC_EXPORT std::shared_ptr client_; -#endif + std::shared_ptr client_reference_guard_; // Aggregation Temporality selector const sdk::metrics::AggregationTemporalitySelector aggregation_temporality_selector_; @@ -73,7 +94,7 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp friend class OtlpGrpcMetricExporterTestPeer; // Store service stub internally. Useful for testing. - std::unique_ptr + std::shared_ptr metrics_service_stub_; /** @@ -83,6 +104,17 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp */ OtlpGrpcMetricExporter( std::unique_ptr stub); + + /** + * Create an OtlpGrpcMetricExporter using the specified service stub and gRPC client. + * Only tests can call this constructor directly. + * @param stub the service stub to be used for exporting + * @param client the gRPC client to use + */ + OtlpGrpcMetricExporter( + std::unique_ptr stub, + const std::shared_ptr &client); + std::atomic is_shutdown_{false}; bool isShutdown() const noexcept; }; diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h index 11b185a384a..5d405609b0e 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h @@ -6,6 +6,7 @@ #include #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,6 +15,8 @@ namespace exporter namespace otlp { +class OtlpGrpcClient; + /** * Factory class for OtlpGrpcMetricExporter. */ @@ -26,10 +29,17 @@ class OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterFactory static std::unique_ptr Create(); /** - * Create a OtlpGrpcMetricExporter. + * Create a OtlpGrpcMetricExporter using the given options. */ static std::unique_ptr Create( const OtlpGrpcMetricExporterOptions &options); + + /** + * Create a OtlpGrpcMetricExporter using the given options and gRPC client. + */ + static std::unique_ptr Create( + const OtlpGrpcMetricExporterOptions &options, + const std::shared_ptr &client); }; } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client.cc index d3d59bce6e8..fe38f16e2ba 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client.cc @@ -78,16 +78,20 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpGrpcAsyncCallData : public OtlpGrpcAsyncCal virtual ~OtlpGrpcAsyncCallData() {} }; } // namespace +#endif struct OtlpGrpcClientAsyncData { + std::chrono::system_clock::duration export_timeout = std::chrono::seconds{10}; // The best performance trade-off of gRPC is having numcpu's threads and one completion queue // per thread, but this exporter should not cost a lot resource and we don't want to create - // too many threads in the process. So we use one completion queue. - grpc::CompletionQueue cq; - + // too many threads in the process. So we use one completion queue and shared context. + std::shared_ptr channel; +#ifdef ENABLE_ASYNC_EXPORT + std::mutex running_calls_lock; + std::unordered_set> running_calls; // Running requests, this is used to limit the number of concurrent requests. std::atomic running_requests{0}; // Request counter is used to record ForceFlush. @@ -98,13 +102,16 @@ struct OtlpGrpcClientAsyncData // Condition variable and mutex to control the concurrency count of running requests. std::mutex session_waker_lock; std::condition_variable session_waker; +#endif + + // Reference count of OtlpGrpcClient + std::atomic reference_count{0}; // Do not use OtlpGrpcClientAsyncData() = default; here, some versions of GCC&Clang have BUGs // and may not initialize the member correctly. See also // https://stackoverflow.com/questions/53408962/try-to-understand-compiler-error-message-default-member-initializer-required-be OtlpGrpcClientAsyncData() {} }; -#endif namespace { @@ -199,6 +206,11 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( ++async_data->start_request_counter; ++async_data->running_requests; + { + std::lock_guard lock{async_data->running_calls_lock}; + async_data->running_calls.insert( + std::static_pointer_cast(call_data)); + } // Some old toolchains can only use gRPC 1.33 and it's experimental. # if defined(GRPC_CPP_VERSION_MAJOR) && \ (GRPC_CPP_VERSION_MAJOR * 1000 + GRPC_CPP_VERSION_MINOR) >= 1039 @@ -207,7 +219,13 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( stub->experimental_async() # endif ->Export(call_data->grpc_context.get(), call_data->request, call_data->response, - [call_data, async_data](::grpc::Status grpc_status) { + [call_data, async_data, export_data_name](::grpc::Status grpc_status) { + { + std::lock_guard lock{async_data->running_calls_lock}; + async_data->running_calls.erase( + std::static_pointer_cast(call_data)); + } + --async_data->running_requests; ++async_data->finished_request_counter; @@ -216,6 +234,13 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( { call_data->export_result = opentelemetry::sdk::common::ExportResult::kSuccess; } + else + { + OTEL_INTERNAL_LOG_ERROR("[OTLP GRPC Client] ERROR: Export " + << export_data_name << " failed with status_code: \"" + << grpc_status.error_code() << "\" error_message: \"" + << grpc_status.error_message() << "\""); + } if (call_data->grpc_async_callback) { @@ -240,18 +265,38 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( #endif } // namespace -OtlpGrpcClient::OtlpGrpcClient() -#ifdef ENABLE_ASYNC_EXPORT - : is_shutdown_(false) -#endif -{} +OtlpGrpcClientReferenceGuard::OtlpGrpcClientReferenceGuard() noexcept : has_value_{false} {} + +OtlpGrpcClientReferenceGuard::~OtlpGrpcClientReferenceGuard() noexcept {} + +OtlpGrpcClient::OtlpGrpcClient(const OtlpGrpcClientOptions &options) : is_shutdown_(false) +{ + std::shared_ptr async_data = MutableAsyncData(options); + async_data->channel = MakeChannel(options); +} OtlpGrpcClient::~OtlpGrpcClient() { -#ifdef ENABLE_ASYNC_EXPORT std::shared_ptr async_data; async_data.swap(async_data_); +#ifdef ENABLE_ASYNC_EXPORT + if (async_data) + { + std::unordered_set> running_calls; + { + std::lock_guard lock(async_data->running_calls_lock); + running_calls = async_data->running_calls; + } + for (auto &call_data : running_calls) + { + if (call_data && call_data->grpc_context) + { + call_data->grpc_context->TryCancel(); + } + } + } + while (async_data && async_data->running_requests.load(std::memory_order_acquire) > 0) { std::unique_lock lock{async_data->session_waker_lock}; @@ -350,21 +395,33 @@ std::unique_ptr OtlpGrpcClient::MakeClientContext( } std::unique_ptr -OtlpGrpcClient::MakeTraceServiceStub(const OtlpGrpcClientOptions &options) +OtlpGrpcClient::MakeTraceServiceStub() { - return proto::collector::trace::v1::TraceService::NewStub(MakeChannel(options)); + if (!async_data_ || !async_data_->channel) + { + return nullptr; + } + return proto::collector::trace::v1::TraceService::NewStub(async_data_->channel); } std::unique_ptr -OtlpGrpcClient::MakeMetricsServiceStub(const OtlpGrpcClientOptions &options) +OtlpGrpcClient::MakeMetricsServiceStub() { - return proto::collector::metrics::v1::MetricsService::NewStub(MakeChannel(options)); + if (!async_data_ || !async_data_->channel) + { + return nullptr; + } + return proto::collector::metrics::v1::MetricsService::NewStub(async_data_->channel); } std::unique_ptr -OtlpGrpcClient::MakeLogsServiceStub(const OtlpGrpcClientOptions &options) +OtlpGrpcClient::MakeLogsServiceStub() { - return proto::collector::logs::v1::LogsService::NewStub(MakeChannel(options)); + if (!async_data_ || !async_data_->channel) + { + return nullptr; + } + return proto::collector::logs::v1::LogsService::NewStub(async_data_->channel); } grpc::Status OtlpGrpcClient::DelegateExport( @@ -397,6 +454,35 @@ grpc::Status OtlpGrpcClient::DelegateExport( return stub->Export(context.get(), request, response); } +void OtlpGrpcClient::AddReference(OtlpGrpcClientReferenceGuard &guard, + const OtlpGrpcClientOptions &options) noexcept +{ + if (false == guard.has_value_.exchange(true, std::memory_order_acq_rel)) + { + MutableAsyncData(options)->reference_count.fetch_add(1, std::memory_order_acq_rel); + } +} + +bool OtlpGrpcClient::RemoveReference(OtlpGrpcClientReferenceGuard &guard) noexcept +{ + auto async_data = async_data_; + if (true == guard.has_value_.exchange(false, std::memory_order_acq_rel)) + { + if (async_data) + { + int64_t left = async_data->reference_count.fetch_sub(1, std::memory_order_acq_rel); + return left <= 1; + } + } + + if (async_data) + { + return async_data->reference_count.load(std::memory_order_acquire) <= 0; + } + + return true; +} + #ifdef ENABLE_ASYNC_EXPORT /** @@ -500,26 +586,37 @@ sdk::common::ExportResult OtlpGrpcClient::DelegateAsyncExport( "log(s)"); } +#endif + std::shared_ptr OtlpGrpcClient::MutableAsyncData( const OtlpGrpcClientOptions &options) { if (!async_data_) { - async_data_ = std::make_shared(); - async_data_->export_timeout = options.timeout; + async_data_ = std::make_shared(); + async_data_->export_timeout = options.timeout; +#ifdef ENABLE_ASYNC_EXPORT async_data_->max_concurrent_requests = options.max_concurrent_requests; +#endif } return async_data_; } -bool OtlpGrpcClient::ForceFlush(std::chrono::microseconds timeout) noexcept +bool OtlpGrpcClient::IsShutdown() const noexcept +{ + return is_shutdown_.load(std::memory_order_acquire); +} + +bool OtlpGrpcClient::ForceFlush( + OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { if (!async_data_) { return true; } +#ifdef ENABLE_ASYNC_EXPORT std::size_t request_counter = async_data_->start_request_counter.load(std::memory_order_acquire); if (request_counter <= async_data_->finished_request_counter.load(std::memory_order_acquire)) { @@ -558,21 +655,46 @@ bool OtlpGrpcClient::ForceFlush(std::chrono::microseconds timeout) noexcept } return timeout_steady > std::chrono::steady_clock::duration::zero(); +#else + return true; +#endif } -bool OtlpGrpcClient::Shutdown(std::chrono::microseconds timeout) noexcept +bool OtlpGrpcClient::Shutdown(OtlpGrpcClientReferenceGuard &guard, + OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { if (!async_data_) { return true; } + bool last_reference_removed = RemoveReference(guard); bool force_flush_result; - if (false == is_shutdown_.exchange(true, std::memory_order_acq_rel)) + if (last_reference_removed && false == is_shutdown_.exchange(true, std::memory_order_acq_rel)) { + OTEL_INTERNAL_LOG_DEBUG("[OTLP GRPC Client] DEBUG: OtlpGrpcClient start to shutdown"); force_flush_result = ForceFlush(timeout); - async_data_->cq.Shutdown(); +#ifdef ENABLE_ASYNC_EXPORT + std::unordered_set> running_calls; + { + std::lock_guard lock(async_data_->running_calls_lock); + running_calls = async_data_->running_calls; + } + if (!running_calls.empty()) + { + OTEL_INTERNAL_LOG_WARN( + "[OTLP GRPC Client] WARN: OtlpGrpcClient shutdown timeout, try to cancel " + << running_calls.size() << " running calls."); + } + for (auto &call_data : running_calls) + { + if (call_data && call_data->grpc_context) + { + call_data->grpc_context->TryCancel(); + } + } +#endif } else { @@ -582,8 +704,6 @@ bool OtlpGrpcClient::Shutdown(std::chrono::microseconds timeout) noexcept return force_flush_result; } -#endif - } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client_factory.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client_factory.cc new file mode 100644 index 00000000000..310593a77a6 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client_factory.cc @@ -0,0 +1,27 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" +#include + +#include "opentelemetry/exporters/otlp/otlp_grpc_client.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +std::shared_ptr OtlpGrpcClientFactory::Create(const OtlpGrpcClientOptions &options) +{ + return std::make_shared(options); +} + +std::shared_ptr OtlpGrpcClientFactory::CreateReferenceGuard() +{ + return std::make_shared(); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter.cc index ed0fc745183..e4012c2ebf6 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter.cc @@ -12,6 +12,7 @@ #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" #include "opentelemetry/sdk_config.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_utils.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -23,22 +24,53 @@ namespace otlp OtlpGrpcExporter::OtlpGrpcExporter() : OtlpGrpcExporter(OtlpGrpcExporterOptions()) {} -OtlpGrpcExporter::OtlpGrpcExporter(const OtlpGrpcExporterOptions &options) - : options_(options), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif - trace_service_stub_(OtlpGrpcClient::MakeTraceServiceStub(options)) -{} +OtlpGrpcExporter::OtlpGrpcExporter(const OtlpGrpcExporterOptions &options) : options_(options) +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); + + trace_service_stub_ = client_->MakeTraceServiceStub(); +} OtlpGrpcExporter::OtlpGrpcExporter( std::unique_ptr stub) + : options_(OtlpGrpcExporterOptions()), trace_service_stub_(std::move(stub)) +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcExporter::OtlpGrpcExporter(const OtlpGrpcExporterOptions &options, + const std::shared_ptr &client) + : options_(options), + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()) +{ + client_->AddReference(*client_reference_guard_, options_); + + trace_service_stub_ = client_->MakeTraceServiceStub(); +} + +OtlpGrpcExporter::OtlpGrpcExporter( + std::unique_ptr stub, + const std::shared_ptr &client) : options_(OtlpGrpcExporterOptions()), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()), trace_service_stub_(std::move(stub)) -{} +{ + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcExporter::~OtlpGrpcExporter() +{ + if (client_) + { + client_->RemoveReference(*client_reference_guard_); + } +} // ----------------------------- Exporter methods ------------------------------ @@ -50,12 +82,21 @@ std::unique_ptr OtlpGrpcExporter::MakeRecordable() noexc sdk::common::ExportResult OtlpGrpcExporter::Export( const nostd::span> &spans) noexcept { - if (isShutdown()) + std::shared_ptr client = client_; + if (isShutdown() || !client) { OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC] Exporting " << spans.size() << " span(s) failed, exporter is shutdown"); return sdk::common::ExportResult::kFailure; } + + if (!trace_service_stub_) + { + OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC] Exporting " + << spans.size() << " span(s) failed, service stub unavailable"); + return sdk::common::ExportResult::kFailure; + } + if (spans.empty()) { return sdk::common::ExportResult::kSuccess; @@ -82,13 +123,16 @@ sdk::common::ExportResult OtlpGrpcExporter::Export( #ifdef ENABLE_ASYNC_EXPORT if (options_.max_concurrent_requests > 1) { - return client_->DelegateAsyncExport( + return client->DelegateAsyncExport( options_, trace_service_stub_.get(), std::move(context), std::move(arena), std::move(*request), - [](opentelemetry::sdk::common::ExportResult result, - std::unique_ptr &&, - const proto::collector::trace::v1::ExportTraceServiceRequest &request, - proto::collector::trace::v1::ExportTraceServiceResponse *) { + // Capture the trace_service_stub_ to ensure it is not destroyed before the callback is + // called. + [trace_service_stub = trace_service_stub_]( + opentelemetry::sdk::common::ExportResult result, + std::unique_ptr &&, + const proto::collector::trace::v1::ExportTraceServiceRequest &request, + proto::collector::trace::v1::ExportTraceServiceResponse *) { if (result != opentelemetry::sdk::common::ExportResult::kSuccess) { OTEL_INTERNAL_LOG_ERROR("[OTLP TRACE GRPC Exporter] ERROR: Export " @@ -125,22 +169,27 @@ sdk::common::ExportResult OtlpGrpcExporter::Export( bool OtlpGrpcExporter::ForceFlush( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { -#ifdef ENABLE_ASYNC_EXPORT - return client_->ForceFlush(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client = client_; + if (!client) + { + return true; + } + return client->ForceFlush(timeout); } bool OtlpGrpcExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { is_shutdown_ = true; -#ifdef ENABLE_ASYNC_EXPORT - return client_->Shutdown(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client; + client.swap(client_); + if (!client) + { + return true; + } + return client->Shutdown(*client_reference_guard_, timeout); } bool OtlpGrpcExporter::isShutdown() const noexcept @@ -148,6 +197,11 @@ bool OtlpGrpcExporter::isShutdown() const noexcept return is_shutdown_; } +const std::shared_ptr &OtlpGrpcExporter::GetClient() const noexcept +{ + return client_; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter_factory.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter_factory.cc index f8ee7e3594c..5ed832a3cd0 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter_factory.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter_factory.cc @@ -27,6 +27,15 @@ std::unique_ptr OtlpGrpcExporterFactory return exporter; } +std::unique_ptr OtlpGrpcExporterFactory::Create( + const OtlpGrpcExporterOptions &options, + const std::shared_ptr &client) +{ + std::unique_ptr exporter( + new OtlpGrpcExporter(options, client)); + return exporter; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter.cc index 1069703f961..fe05be7b304 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter.cc @@ -6,19 +6,20 @@ #include "opentelemetry/common/macros.h" #include "opentelemetry/exporters/otlp/otlp_grpc_client.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" // clang-format off - #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on -#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" #include "opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h" +#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - // clang-format on #include "opentelemetry/sdk/common/global_log_handler.h" @@ -36,21 +37,54 @@ OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter() OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( const OtlpGrpcLogRecordExporterOptions &options) - : options_(options), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif - log_service_stub_(OtlpGrpcClient::MakeLogsServiceStub(options)) -{} + : options_(options) +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); + + log_service_stub_ = client_->MakeLogsServiceStub(); +} OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( std::unique_ptr stub) + : options_(OtlpGrpcLogRecordExporterOptions()), log_service_stub_(std::move(stub)) +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( + const OtlpGrpcLogRecordExporterOptions &options, + const std::shared_ptr &client) + : options_(options), + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()) +{ + client_->AddReference(*client_reference_guard_, options_); + + log_service_stub_ = client_->MakeLogsServiceStub(); +} + +OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( + std::unique_ptr stub, + const std::shared_ptr &client) : options_(OtlpGrpcLogRecordExporterOptions()), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()), log_service_stub_(std::move(stub)) -{} +{ + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcLogRecordExporter::~OtlpGrpcLogRecordExporter() +{ + if (client_) + { + client_->RemoveReference(*client_reference_guard_); + } +} // ----------------------------- Exporter methods ------------------------------ @@ -63,12 +97,20 @@ OtlpGrpcLogRecordExporter::MakeRecordable() noexcept opentelemetry::sdk::common::ExportResult OtlpGrpcLogRecordExporter::Export( const nostd::span> &logs) noexcept { - if (isShutdown()) + std::shared_ptr client = client_; + if (isShutdown() || !client) { OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC log] Exporting " << logs.size() << " log(s) failed, exporter is shutdown"); return sdk::common::ExportResult::kFailure; } + if (!log_service_stub_) + { + OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC] Exporting " << logs.size() + << " log(s) failed, service stub unavailable"); + return sdk::common::ExportResult::kFailure; + } + if (logs.empty()) { return sdk::common::ExportResult::kSuccess; @@ -95,13 +137,16 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcLogRecordExporter::Export( #ifdef ENABLE_ASYNC_EXPORT if (options_.max_concurrent_requests > 1) { - return client_->DelegateAsyncExport( + return client->DelegateAsyncExport( options_, log_service_stub_.get(), std::move(context), std::move(arena), std::move(*request), - [](opentelemetry::sdk::common::ExportResult result, - std::unique_ptr &&, - const proto::collector::logs::v1::ExportLogsServiceRequest &request, - proto::collector::logs::v1::ExportLogsServiceResponse *) { + // Capture log_service_stub by value to ensure it is not destroyed before the callback is + // called. + [log_service_stub = log_service_stub_]( + opentelemetry::sdk::common::ExportResult result, + std::unique_ptr &&, + const proto::collector::logs::v1::ExportLogsServiceRequest &request, + proto::collector::logs::v1::ExportLogsServiceResponse *) { if (result != opentelemetry::sdk::common::ExportResult::kSuccess) { OTEL_INTERNAL_LOG_ERROR("[OTLP LOG GRPC Exporter] ERROR: Export " @@ -139,21 +184,26 @@ bool OtlpGrpcLogRecordExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { is_shutdown_ = true; -#ifdef ENABLE_ASYNC_EXPORT - return client_->Shutdown(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client; + client.swap(client_); + if (!client) + { + return true; + } + return client->Shutdown(*client_reference_guard_, timeout); } bool OtlpGrpcLogRecordExporter::ForceFlush( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { -#ifdef ENABLE_ASYNC_EXPORT - return client_->ForceFlush(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client = client_; + if (!client) + { + return true; + } + return client->ForceFlush(timeout); } bool OtlpGrpcLogRecordExporter::isShutdown() const noexcept @@ -161,6 +211,11 @@ bool OtlpGrpcLogRecordExporter::isShutdown() const noexcept return is_shutdown_; } +const std::shared_ptr &OtlpGrpcLogRecordExporter::GetClient() const noexcept +{ + return client_; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc index 7229de569a9..4b519e37e86 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc @@ -28,6 +28,15 @@ OtlpGrpcLogRecordExporterFactory::Create(const OtlpGrpcLogRecordExporterOptions return exporter; } +std::unique_ptr +OtlpGrpcLogRecordExporterFactory::Create(const OtlpGrpcLogRecordExporterOptions &options, + const std::shared_ptr &client) +{ + std::unique_ptr exporter( + new OtlpGrpcLogRecordExporter(options, client)); + return exporter; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter.cc index 6a78149eaad..1723dd557af 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter.cc @@ -6,6 +6,7 @@ #include "opentelemetry/common/macros.h" #include "opentelemetry/exporters/otlp/otlp_grpc_client.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" @@ -24,24 +25,57 @@ OtlpGrpcMetricExporter::OtlpGrpcMetricExporter() OtlpGrpcMetricExporter::OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options) : options_(options), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif aggregation_temporality_selector_{ - OtlpMetricUtils::ChooseTemporalitySelector(options_.aggregation_temporality)}, - metrics_service_stub_(OtlpGrpcClient::MakeMetricsServiceStub(options)) -{} + OtlpMetricUtils::ChooseTemporalitySelector(options_.aggregation_temporality)} +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); + + metrics_service_stub_ = client_->MakeMetricsServiceStub(); +} OtlpGrpcMetricExporter::OtlpGrpcMetricExporter( std::unique_ptr stub) : options_(OtlpGrpcMetricExporterOptions()), -#ifdef ENABLE_ASYNC_EXPORT - client_(std::make_shared()), -#endif aggregation_temporality_selector_{ OtlpMetricUtils::ChooseTemporalitySelector(options_.aggregation_temporality)}, metrics_service_stub_(std::move(stub)) -{} +{ + client_ = OtlpGrpcClientFactory::Create(options_); + client_reference_guard_ = OtlpGrpcClientFactory::CreateReferenceGuard(); + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcMetricExporter::OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options, + const std::shared_ptr &client) + : options_(options), + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()) +{ + client_->AddReference(*client_reference_guard_, options_); + + metrics_service_stub_ = client_->MakeMetricsServiceStub(); +} + +OtlpGrpcMetricExporter::OtlpGrpcMetricExporter( + std::unique_ptr stub, + const std::shared_ptr &client) + : options_(OtlpGrpcMetricExporterOptions()), + client_(client), + client_reference_guard_(OtlpGrpcClientFactory::CreateReferenceGuard()), + metrics_service_stub_(std::move(stub)) +{ + client_->AddReference(*client_reference_guard_, options_); +} + +OtlpGrpcMetricExporter::~OtlpGrpcMetricExporter() +{ + if (client_) + { + client_->RemoveReference(*client_reference_guard_); + } +} // ----------------------------- Exporter methods ------------------------------ @@ -54,14 +88,23 @@ sdk::metrics::AggregationTemporality OtlpGrpcMetricExporter::GetAggregationTempo opentelemetry::sdk::common::ExportResult OtlpGrpcMetricExporter::Export( const opentelemetry::sdk::metrics::ResourceMetrics &data) noexcept { - - if (isShutdown()) + std::shared_ptr client = client_; + if (isShutdown() || !client) { OTEL_INTERNAL_LOG_ERROR("[OTLP METRICS gRPC] Exporting " << data.scope_metric_data_.size() << " metric(s) failed, exporter is shutdown"); return sdk::common::ExportResult::kFailure; } + + if (!metrics_service_stub_) + { + OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC] Exporting " + << data.scope_metric_data_.size() + << " metric(s) failed, service stub unavailable"); + return sdk::common::ExportResult::kFailure; + } + if (data.scope_metric_data_.empty()) { return sdk::common::ExportResult::kSuccess; @@ -88,13 +131,16 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcMetricExporter::Export( #ifdef ENABLE_ASYNC_EXPORT if (options_.max_concurrent_requests > 1) { - return client_->DelegateAsyncExport( + return client->DelegateAsyncExport( options_, metrics_service_stub_.get(), std::move(context), std::move(arena), std::move(*request), - [](opentelemetry::sdk::common::ExportResult result, - std::unique_ptr &&, - const proto::collector::metrics::v1::ExportMetricsServiceRequest &request, - proto::collector::metrics::v1::ExportMetricsServiceResponse *) { + // Capture the metrics_service_stub_ to ensure it is not destroyed before the callback is + // called. + [metrics_service_stub = metrics_service_stub_]( + opentelemetry::sdk::common::ExportResult result, + std::unique_ptr &&, + const proto::collector::metrics::v1::ExportMetricsServiceRequest &request, + proto::collector::metrics::v1::ExportMetricsServiceResponse *) { if (result != opentelemetry::sdk::common::ExportResult::kSuccess) { OTEL_INTERNAL_LOG_ERROR("[OTLP METRIC GRPC Exporter] ERROR: Export " @@ -131,22 +177,27 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcMetricExporter::Export( bool OtlpGrpcMetricExporter::ForceFlush( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { -#ifdef ENABLE_ASYNC_EXPORT - return client_->ForceFlush(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client = client_; + if (!client) + { + return true; + } + return client->ForceFlush(timeout); } bool OtlpGrpcMetricExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { is_shutdown_ = true; -#ifdef ENABLE_ASYNC_EXPORT - return client_->Shutdown(timeout); -#else - return true; -#endif + // Maybe already shutdown, we need to keep thread-safety here. + std::shared_ptr client; + client.swap(client_); + if (!client) + { + return true; + } + return client->Shutdown(*client_reference_guard_, timeout); } bool OtlpGrpcMetricExporter::isShutdown() const noexcept @@ -154,6 +205,11 @@ bool OtlpGrpcMetricExporter::isShutdown() const noexcept return is_shutdown_; } +const std::shared_ptr &OtlpGrpcMetricExporter::GetClient() const noexcept +{ + return client_; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc index c26035a8df1..244d2757220 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc @@ -28,6 +28,15 @@ OtlpGrpcMetricExporterFactory::Create(const OtlpGrpcMetricExporterOptions &optio return exporter; } +std::unique_ptr +OtlpGrpcMetricExporterFactory::Create(const OtlpGrpcMetricExporterOptions &options, + const std::shared_ptr &client) +{ + std::unique_ptr exporter( + new OtlpGrpcMetricExporter(options, client)); + return exporter; +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc index 876719fa1ed..c330ffae2f8 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc @@ -989,6 +989,7 @@ OtlpHttpClient::createSession( request->SetBody(body_vec); request->ReplaceHeader("Content-Type", content_type); request->ReplaceHeader("User-Agent", options_.user_agent); + request->EnableLogging(options_.console_debug); if (options_.compression == "gzip") { diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_metric_utils.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_metric_utils.cc index 103135ad1d8..a7220e98324 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_metric_utils.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_metric_utils.cc @@ -356,6 +356,7 @@ sdk::metrics::AggregationTemporality OtlpMetricUtils::DeltaTemporalitySelector( case sdk::metrics::InstrumentType::kObservableCounter: case sdk::metrics::InstrumentType::kHistogram: case sdk::metrics::InstrumentType::kObservableGauge: + case sdk::metrics::InstrumentType::kGauge: return sdk::metrics::AggregationTemporality::kDelta; case sdk::metrics::InstrumentType::kUpDownCounter: case sdk::metrics::InstrumentType::kObservableUpDownCounter: @@ -381,6 +382,7 @@ sdk::metrics::AggregationTemporality OtlpMetricUtils::LowMemoryTemporalitySelect case sdk::metrics::InstrumentType::kHistogram: return sdk::metrics::AggregationTemporality::kDelta; case sdk::metrics::InstrumentType::kObservableCounter: + case sdk::metrics::InstrumentType::kGauge: case sdk::metrics::InstrumentType::kObservableGauge: case sdk::metrics::InstrumentType::kUpDownCounter: case sdk::metrics::InstrumentType::kObservableUpDownCounter: diff --git a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc index c383cc85edd..a2fb62dab02 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc @@ -3,6 +3,7 @@ #include +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" @@ -14,6 +15,8 @@ # error "protobuf should not be included" #endif +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -31,6 +34,25 @@ TEST(OtlpGrpcExporterFactoryTest, BuildTest) EXPECT_TRUE(exporter != nullptr); } +TEST(OtlpGrpcExporterFactoryTest, ShareClient) +{ + OtlpGrpcExporterOptions opts; + opts.endpoint = "localhost:45454"; + + std::shared_ptr client = OtlpGrpcClientFactory::Create(opts); + std::unique_ptr exporter1 = + OtlpGrpcExporterFactory::Create(opts, client); + + std::unique_ptr exporter2 = + OtlpGrpcExporterFactory::Create(opts, client); + + EXPECT_TRUE(exporter1 != nullptr); + EXPECT_TRUE(exporter2 != nullptr); + + EXPECT_TRUE(static_cast(exporter1.get())->GetClient().get() == client.get()); + EXPECT_TRUE(static_cast(exporter2.get())->GetClient().get() == client.get()); +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc index cb1d1849aac..0d0ab17d623 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc @@ -3,6 +3,7 @@ #include +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" @@ -14,6 +15,8 @@ # error "protobuf should not be included" #endif +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -31,6 +34,27 @@ TEST(OtlpGrpcLogRecordExporterFactoryTest, BuildTest) EXPECT_TRUE(exporter != nullptr); } +TEST(OtlpGrpcLogRecordExporterFactoryTest, ShareClient) +{ + OtlpGrpcLogRecordExporterOptions opts; + opts.endpoint = "localhost:45454"; + + std::shared_ptr client = OtlpGrpcClientFactory::Create(opts); + std::unique_ptr exporter1 = + OtlpGrpcLogRecordExporterFactory::Create(opts, client); + + std::unique_ptr exporter2 = + OtlpGrpcLogRecordExporterFactory::Create(opts, client); + + EXPECT_TRUE(exporter1 != nullptr); + EXPECT_TRUE(exporter2 != nullptr); + + EXPECT_TRUE(static_cast(exporter1.get())->GetClient().get() == + client.get()); + EXPECT_TRUE(static_cast(exporter2.get())->GetClient().get() == + client.get()); +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc index 90827f576f8..a2604de0962 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc @@ -3,15 +3,21 @@ #include +#include "opentelemetry/exporters/otlp/otlp_grpc_client.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +// clang-format on #include "opentelemetry/proto/collector/logs/v1/logs_service_mock.grpc.pb.h" #include "opentelemetry/proto/collector/trace/v1/trace_service_mock.grpc.pb.h" +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +// clang-format on #include "opentelemetry/logs/provider.h" #include "opentelemetry/sdk/logs/batch_log_record_processor.h" @@ -188,6 +194,22 @@ class OtlpGrpcLogRecordExporterTestPeer : public ::testing::Test new OtlpGrpcExporter(std::move(stub_interface))); } + std::unique_ptr GetExporter( + std::unique_ptr &stub_interface, + const std::shared_ptr &client) + { + return std::unique_ptr( + new OtlpGrpcLogRecordExporter(std::move(stub_interface), std::move(client))); + } + + std::unique_ptr GetExporter( + std::unique_ptr &stub_interface, + const std::shared_ptr &client) + { + return std::unique_ptr( + new OtlpGrpcExporter(std::move(stub_interface), std::move(client))); + } + // Get the options associated with the given exporter. const OtlpGrpcLogRecordExporterOptions &GetOptions( std::unique_ptr &exporter) @@ -334,6 +356,116 @@ TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportIntegrationTest) trace_provider = opentelemetry::nostd::shared_ptr(); } +// Create spans, let processor call Export() and share client object between trace and logs +TEST_F(OtlpGrpcLogRecordExporterTestPeer, ShareClientTest) +{ + std::shared_ptr shared_client = + OtlpGrpcClientFactory::Create(OtlpGrpcLogRecordExporterOptions()); + + auto mock_stub = new OtlpMockLogsServiceStub(); + std::unique_ptr stub_interface(mock_stub); + + auto exporter = GetExporter(stub_interface, shared_client); + + bool attribute_storage_bool_value[] = {true, false, true}; + int32_t attribute_storage_int32_value[] = {1, 2}; + uint32_t attribute_storage_uint32_value[] = {3, 4}; + int64_t attribute_storage_int64_value[] = {5, 6}; + uint64_t attribute_storage_uint64_value[] = {7, 8}; + double attribute_storage_double_value[] = {3.2, 3.3}; + opentelemetry::nostd::string_view attribute_storage_string_value[] = {"vector", "string"}; + + auto provider = nostd::shared_ptr(new sdk::logs::LoggerProvider()); + provider->AddProcessor( + std::unique_ptr(new sdk::logs::BatchLogRecordProcessor( + std::move(exporter), 5, std::chrono::milliseconds(256), 1))); + + EXPECT_CALL(*mock_stub, Export(_, _, _)) + .Times(Exactly(1)) + .WillRepeatedly(Return(grpc::Status::OK)); + + uint8_t trace_id_bin[opentelemetry::trace::TraceId::kSize] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + opentelemetry::trace::TraceId trace_id{trace_id_bin}; + uint8_t span_id_bin[opentelemetry::trace::SpanId::kSize] = {'7', '6', '5', '4', + '3', '2', '1', '0'}; + opentelemetry::trace::SpanId span_id{span_id_bin}; + + auto trace_mock_stub = new OtlpMockTraceServiceStub(); + std::unique_ptr trace_stub_interface( + trace_mock_stub); + + auto trace_provider = opentelemetry::nostd::shared_ptr( + opentelemetry::sdk::trace::TracerProviderFactory::Create( + opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create( + GetExporter(trace_stub_interface, shared_client)))); + + // Trace and Logs should both receive datas when links static gRPC on ELF ABI. + EXPECT_CALL(*trace_mock_stub, Export(_, _, _)) + .Times(AtLeast(2)) + .WillRepeatedly(Return(grpc::Status::OK)); + + { + const std::string schema_url{"https://opentelemetry.io/schemas/1.11.0"}; + + auto tracer = trace_provider->GetTracer("opentelelemtry_library", "", schema_url); + auto copy_trace_provider = trace_provider; + opentelemetry::trace::Provider::SetTracerProvider(std::move(copy_trace_provider)); + auto trace_span = tracer->StartSpan("test_log"); + opentelemetry::trace::Scope trace_scope{trace_span}; + + auto logger = provider->GetLogger("test", "opentelelemtry_library", "", schema_url, + {{"scope_key1", "scope_value"}, {"scope_key2", 2}}); + std::unordered_map attributes; + attributes["service.name"] = "unit_test_service"; + attributes["tenant.id"] = "test_user"; + attributes["bool_value"] = true; + attributes["int32_value"] = static_cast(1); + attributes["uint32_value"] = static_cast(2); + attributes["int64_value"] = static_cast(0x1100000000LL); + attributes["uint64_value"] = static_cast(0x1200000000ULL); + attributes["double_value"] = static_cast(3.1); + attributes["vec_bool_value"] = attribute_storage_bool_value; + attributes["vec_int32_value"] = attribute_storage_int32_value; + attributes["vec_uint32_value"] = attribute_storage_uint32_value; + attributes["vec_int64_value"] = attribute_storage_int64_value; + attributes["vec_uint64_value"] = attribute_storage_uint64_value; + attributes["vec_double_value"] = attribute_storage_double_value; + attributes["vec_string_value"] = attribute_storage_string_value; + logger->EmitLogRecord(opentelemetry::logs::Severity::kInfo, "Log message", attributes, + trace_span->GetContext(), std::chrono::system_clock::now()); + } + + // Shudown logs, but tracer still works + provider->Shutdown(); + EXPECT_FALSE(shared_client->IsShutdown()); + + { + const std::string schema_url{"https://opentelemetry.io/schemas/1.11.0"}; + + auto tracer = trace_provider->GetTracer("opentelelemtry_library", "", schema_url); + auto trace_span = tracer->StartSpan("test_log"); + opentelemetry::trace::Scope trace_scope{trace_span}; + + auto logger = provider->GetLogger("test", "opentelelemtry_library", "", schema_url, + {{"scope_key1", "scope_value"}, {"scope_key2", 2}}); + std::unordered_map attributes; + attributes["service.name"] = "unit_test_service"; + attributes["tenant.id"] = "test_user"; + logger->EmitLogRecord(opentelemetry::logs::Severity::kInfo, "Log message", attributes, + trace_span->GetContext(), std::chrono::system_clock::now()); + } + + // All references are released, client should also be shutdown + trace_provider->Shutdown(); + EXPECT_TRUE(shared_client->IsShutdown()); + + opentelemetry::trace::Provider::SetTracerProvider( + opentelemetry::nostd::shared_ptr( + new opentelemetry::trace::NoopTracerProvider())); + trace_provider = opentelemetry::nostd::shared_ptr(); +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc index b1d473e8dad..ecad49bee19 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc @@ -3,6 +3,7 @@ #include +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" @@ -14,6 +15,8 @@ # error "protobuf should not be included" #endif +#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -31,6 +34,27 @@ TEST(OtlpGrpcMetricExporterFactory, BuildTest) EXPECT_TRUE(exporter != nullptr); } +TEST(OtlpGrpcMetricExporterFactory, ShareClient) +{ + OtlpGrpcMetricExporterOptions opts; + opts.endpoint = "localhost:45454"; + + std::shared_ptr client = OtlpGrpcClientFactory::Create(opts); + std::unique_ptr exporter1 = + OtlpGrpcMetricExporterFactory::Create(opts, client); + + std::unique_ptr exporter2 = + OtlpGrpcMetricExporterFactory::Create(opts, client); + + EXPECT_TRUE(exporter1 != nullptr); + EXPECT_TRUE(exporter2 != nullptr); + + EXPECT_TRUE(static_cast(exporter1.get())->GetClient().get() == + client.get()); + EXPECT_TRUE(static_cast(exporter2.get())->GetClient().get() == + client.get()); +} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_log_recordable_test.cc b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_log_recordable_test.cc index bcecbb8d8f7..e5d6701e46c 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_log_recordable_test.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_log_recordable_test.cc @@ -8,7 +8,6 @@ #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/sdk/logs/read_write_log_record.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h b/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h index 5d8b4932fc2..da9d124029e 100644 --- a/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h @@ -28,6 +28,12 @@ struct PrometheusExporterOptions // Populating otel_scope_name/otel_scope_labels attributes bool without_otel_scope = false; + + // Option to export metrics without the unit suffix + bool without_units = false; + + // Option to export metrics without the type suffix + bool without_type_suffix = false; }; } // namespace metrics diff --git a/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h b/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h index ccf3d03ff37..29c0f66daf9 100644 --- a/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h +++ b/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h @@ -30,12 +30,18 @@ class PrometheusExporterUtils * @param populate_target_info whether to populate target_info * @param without_otel_scope whether to populate otel_scope_name and otel_scope_version * attributes + * @param without_units exporter configuration controlling whether to append unit suffix in + * the exported metrics. + * @param without_type_suffix exporter configuration controlling whether to append type suffix in + * the exported metrics. * @return a collection of translated metrics that is acceptable by Prometheus */ static std::vector<::prometheus::MetricFamily> TranslateToPrometheus( const sdk::metrics::ResourceMetrics &data, bool populate_target_info = true, - bool without_otel_scope = false); + bool without_otel_scope = false, + bool without_units = false, + bool without_type_suffix = false); private: /** @@ -61,7 +67,9 @@ class PrometheusExporterUtils static std::string MapToPrometheusName(const std::string &name, const std::string &unit, - ::prometheus::MetricType prometheus_type); + ::prometheus::MetricType prometheus_type, + bool without_units, + bool without_type_suffix); /** * A utility function that returns the equivalent Prometheus name for the provided OTLP metric diff --git a/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_options.cc b/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_options.cc index f2c49f7a579..a9de8f4eb4d 100644 --- a/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_options.cc @@ -48,10 +48,33 @@ inline bool GetPrometheusPopulateTargetInfo() return exists ? setting : true; } +inline bool GetPrometheusWithoutUnits() +{ + constexpr char kPrometheusWithoutUnits[] = "OTEL_CPP_PROMETHEUS_EXPORTER_WITHOUT_UNITS"; + bool setting; + const auto exists = + opentelemetry::sdk::common::GetBoolEnvironmentVariable(kPrometheusWithoutUnits, setting); + + return exists ? setting : false; +} + +inline bool GetPrometheusWithoutTypeSuffix() +{ + constexpr char kPrometheusWithoutTypeSuffix[] = + "OTEL_CPP_PROMETHEUS_EXPORTER_WITHOUT_TYPE_SUFFIX"; + bool setting; + const auto exists = + opentelemetry::sdk::common::GetBoolEnvironmentVariable(kPrometheusWithoutTypeSuffix, setting); + + return exists ? setting : false; +} + PrometheusExporterOptions::PrometheusExporterOptions() : url(GetPrometheusDefaultHttpEndpoint()), populate_target_info(GetPrometheusPopulateTargetInfo()), - without_otel_scope(GetPrometheusWithoutOtelScope()) + without_otel_scope(GetPrometheusWithoutOtelScope()), + without_units(GetPrometheusWithoutUnits()), + without_type_suffix(GetPrometheusWithoutTypeSuffix()) {} } // namespace metrics diff --git a/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_utils.cc b/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_utils.cc index 77fcd56ad27..f54b129ab81 100644 --- a/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_utils.cc +++ b/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_utils.cc @@ -16,12 +16,9 @@ #include "opentelemetry/common/macros.h" #include "opentelemetry/exporters/prometheus/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" -#include "opentelemetry/trace/semantic_conventions.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" namespace prometheus_client = ::prometheus; namespace metric_sdk = opentelemetry::sdk::metrics; @@ -102,13 +99,15 @@ std::string SanitizeLabel(std::string label_key) * Helper function to convert OpenTelemetry metrics data collection * to Prometheus metrics data collection * - * @param records a collection of metrics in OpenTelemetry + * @param data a collection of metrics in OpenTelemetry * @return a collection of translated metrics that is acceptable by Prometheus */ std::vector PrometheusExporterUtils::TranslateToPrometheus( const sdk::metrics::ResourceMetrics &data, bool populate_target_info, - bool without_otel_scope) + bool without_otel_scope, + bool without_units, + bool without_type_suffix) { // initialize output vector @@ -150,7 +149,8 @@ std::vector PrometheusExporterUtils::TranslateT } const prometheus_client::MetricType type = TranslateType(kind, is_monotonic); metric_family.name = MapToPrometheusName(metric_data.instrument_descriptor.name_, - metric_data.instrument_descriptor.unit_, type); + metric_data.instrument_descriptor.unit_, type, + without_units, without_type_suffix); metric_family.type = type; const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope = without_otel_scope ? nullptr : instrumentation_info.scope_; @@ -492,34 +492,43 @@ std::string PrometheusExporterUtils::CleanUpString(const std::string &str) std::string PrometheusExporterUtils::MapToPrometheusName( const std::string &name, const std::string &unit, - prometheus_client::MetricType prometheus_type) + prometheus_client::MetricType prometheus_type, + bool without_units, + bool without_type_suffix) { - auto sanitized_name = SanitizeNames(name); - std::string prometheus_equivalent_unit = GetEquivalentPrometheusUnit(unit); - - // Append prometheus unit if not null or empty. - if (!prometheus_equivalent_unit.empty() && - sanitized_name.find(prometheus_equivalent_unit) == std::string::npos) - { - sanitized_name += "_" + prometheus_equivalent_unit; - } - - // Special case - counter - if (prometheus_type == prometheus_client::MetricType::Counter) - { - auto t_pos = sanitized_name.rfind("_total"); - bool ends_with_total = t_pos == sanitized_name.size() - 6; - if (!ends_with_total) + auto sanitized_name = SanitizeNames(name); + // append unit suffixes + if (!without_units) + { + std::string prometheus_equivalent_unit = GetEquivalentPrometheusUnit(unit); + // Append prometheus unit if not null or empty. + if (!prometheus_equivalent_unit.empty() && + sanitized_name.find(prometheus_equivalent_unit) == std::string::npos) + { + sanitized_name += "_" + prometheus_equivalent_unit; + } + // Special case - gauge + if (unit == "1" && prometheus_type == prometheus_client::MetricType::Gauge && + sanitized_name.find("ratio") == std::string::npos) { - sanitized_name += "_total"; + // this is replacing the unit name + sanitized_name += "_ratio"; } } - // Special case - gauge - if (unit == "1" && prometheus_type == prometheus_client::MetricType::Gauge && - sanitized_name.find("ratio") == std::string::npos) + // append type suffixes + if (!without_type_suffix) { - sanitized_name += "_ratio"; + // Special case - counter + if (prometheus_type == prometheus_client::MetricType::Counter) + { + auto t_pos = sanitized_name.rfind("_total"); + bool ends_with_total = t_pos == sanitized_name.size() - 6; + if (!ends_with_total) + { + sanitized_name += "_total"; + } + } } return CleanUpString(SanitizeNames(sanitized_name)); diff --git a/deps/opentelemetry-cpp/exporters/prometheus/test/exporter_utils_test.cc b/deps/opentelemetry-cpp/exporters/prometheus/test/exporter_utils_test.cc index 7ad5eee1fd8..76ec869a6f6 100644 --- a/deps/opentelemetry-cpp/exporters/prometheus/test/exporter_utils_test.cc +++ b/deps/opentelemetry-cpp/exporters/prometheus/test/exporter_utils_test.cc @@ -54,9 +54,12 @@ class SanitizeNameTester } static std::string mapToPrometheusName(const std::string &name, const std::string &unit, - prometheus_client::MetricType prometheus_type) + prometheus_client::MetricType prometheus_type, + bool without_units = false, + bool without_type_suffix = false) { - return PrometheusExporterUtils::MapToPrometheusName(name, unit, prometheus_type); + return PrometheusExporterUtils::MapToPrometheusName(name, unit, prometheus_type, without_units, + without_type_suffix); } }; } // namespace metrics @@ -419,6 +422,93 @@ TEST(PrometheusExporterUtils, ConvertRateExpressedToPrometheusUnit) "_per_minute"); } +TEST(PromentheusExporterUtils, PrometheusNameMapping) +{ + // General test cases on unit expansions and name sanitization + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric___name", "g", prometheus::MetricType::Counter), + "sample_metric_name_grams_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "s", prometheus::MetricType::Counter), + "sample_metric_name_seconds_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "s", prometheus::MetricType::Gauge), + "sample_metric_name_seconds"); + // Test without_units & without_type_suffix with Counters and unit = 1 + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter), + "sample_metric_name_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter, true, false), + "sample_metric_name_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter, false, true), + "sample_metric_name"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter, true, true), + "sample_metric_name"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Counter, true, true), + "sample_metric_name"); + // Test without_units & without_type_suffix with Counters and non-special units + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "%", prometheus::MetricType::Counter), + "sample_metric_name_percent_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "m", prometheus::MetricType::Counter, true, false), + "sample_metric_name_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "By", prometheus::MetricType::Counter, false, true), + "sample_metric_name_bytes"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "s", prometheus::MetricType::Counter, true, true), + "sample_metric_name"); + // Special case Gauges & ratio + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Gauge), + "sample_metric_name_ratio"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Gauge, false, true), + "sample_metric_name_ratio"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Gauge, true, false), + "sample_metric_name"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "1", prometheus::MetricType::Gauge, true, true), + "sample_metric_name"); + // Test without_type_suffix affects only counters + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Counter), + "sample_metric_name_hertz_total"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Counter, false, true), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Gauge), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Gauge, false, true), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Histogram), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Histogram, false, true), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Summary), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Summary, false, true), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Info), + "sample_metric_name_hertz"); + ASSERT_EQ(exporter::metrics::SanitizeNameTester::mapToPrometheusName( + "sample_metric_name", "Hz", prometheus::MetricType::Info, false, true), + "sample_metric_name_hertz"); +} + TEST_F(AttributeCollisionTest, JoinsCollidingKeys) { CheckTranslation({{"foo.a", "value1"}, {"foo_a", "value2"}}, {{"foo_a", "value1;value2"}, diff --git a/deps/opentelemetry-cpp/exporters/zipkin/src/recordable.cc b/deps/opentelemetry-cpp/exporters/zipkin/src/recordable.cc index 69899e7fada..8b60faef711 100644 --- a/deps/opentelemetry-cpp/exporters/zipkin/src/recordable.cc +++ b/deps/opentelemetry-cpp/exporters/zipkin/src/recordable.cc @@ -21,7 +21,7 @@ #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "opentelemetry/semconv/service_attributes.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/span_metadata.h" @@ -244,9 +244,9 @@ void Recordable::SetResource(const sdk::resource::Resource &resource) noexcept { // only service.name attribute is supported by specs as of now. auto attributes = resource.GetAttributes(); - if (attributes.find(SemanticConventions::kServiceName) != attributes.end()) + if (attributes.find(semconv::service::kServiceName) != attributes.end()) { - service_name_ = nostd::get(attributes[SemanticConventions::kServiceName]); + service_name_ = nostd::get(attributes[semconv::service::kServiceName]); } } diff --git a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h index 902981f3924..ef65388fe1f 100644 --- a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h +++ b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h @@ -102,6 +102,8 @@ class Request : public opentelemetry::ext::http::client::Request compression_ = compression; } + void EnableLogging(bool is_log_enabled) noexcept override { is_log_enabled_ = is_log_enabled; } + public: opentelemetry::ext::http::client::Method method_; opentelemetry::ext::http::client::HttpSslOptions ssl_options_; @@ -111,6 +113,7 @@ class Request : public opentelemetry::ext::http::client::Request std::chrono::milliseconds timeout_ms_{5000}; // ms opentelemetry::ext::http::client::Compression compression_{ opentelemetry::ext::http::client::Compression::kNone}; + bool is_log_enabled_{false}; }; class Response : public opentelemetry::ext::http::client::Response diff --git a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h index b6654ce3ad4..b94c53b2d01 100644 --- a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h +++ b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h @@ -102,6 +102,12 @@ class HttpOperation static size_t ReadMemoryCallback(char *buffer, size_t size, size_t nitems, void *userp); + static int CurlLoggerCallback(const CURL * /* handle */, + curl_infotype type, + const char *data, + size_t size, + void * /* clientp */) noexcept; + #if LIBCURL_VERSION_NUM >= 0x075000 static int PreRequestCallback(void *clientp, char *conn_primary_ip, @@ -152,7 +158,8 @@ class HttpOperation // Default connectivity and response size options bool is_raw_response = false, std::chrono::milliseconds http_conn_timeout = default_http_conn_timeout, - bool reuse_connection = false); + bool reuse_connection = false, + bool is_log_enabled = false); /** * Destroy CURL instance @@ -300,6 +307,8 @@ class HttpOperation const opentelemetry::ext::http::client::Compression &compression_; + const bool is_log_enabled_; + // Processed response headers and body long response_code_; std::vector response_headers_; diff --git a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/http_client.h b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/http_client.h index d17215da9bb..e467f9ef63f 100644 --- a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/http_client.h +++ b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/http_client.h @@ -245,6 +245,8 @@ class Request virtual void SetCompression(const Compression &compression) noexcept = 0; + virtual void EnableLogging(bool is_log_enabled) noexcept = 0; + virtual ~Request() = default; }; diff --git a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/common/url_parser.h b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/common/url_parser.h index 75f53ce9439..c5fe156aa6f 100644 --- a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/common/url_parser.h +++ b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/common/url_parser.h @@ -3,9 +3,11 @@ #pragma once -#include +#include #include +#include #include +#include #include "opentelemetry/version.h" @@ -33,7 +35,7 @@ class UrlParser std::string query_; bool success_; - UrlParser(std::string url) : url_(url), success_(true) + UrlParser(std::string url) : url_(std::move(url)), success_(true) { if (url_.length() == 0) { @@ -49,15 +51,15 @@ class UrlParser } else { - scheme_ = std::string(url_.begin() + cpos, url_.begin() + pos); + scheme_ = url_.substr(cpos, pos - cpos); cpos = pos + 3; } // credentials - size_t pos1 = url_.find_first_of("@", cpos); - size_t pos2 = url_.find_first_of("/", cpos); + size_t pos1 = url_.find_first_of('@', cpos); if (pos1 != std::string::npos) { + size_t pos2 = url_.find_first_of('/', cpos); // TODO - handle credentials if (pos2 == std::string::npos || pos1 < pos2) { @@ -71,15 +73,19 @@ class UrlParser { // port missing. Used default 80 / 443 if (scheme_ == "http") + { port_ = 80; - if (scheme_ == "https") + } + else if (scheme_ == "https") + { port_ = 443; + } } else { // port present is_port = true; - host_ = std::string(url_.begin() + cpos, url_.begin() + pos); + host_ = url_.substr(cpos, pos - cpos); cpos = pos + 1; } pos = url_.find_first_of("/?", cpos); @@ -88,23 +94,23 @@ class UrlParser path_ = std::string("/"); // use default path if (is_port) { - port_ = static_cast( - std::stoi(std::string(url_.begin() + cpos, url_.begin() + url_.length()))); + auto port_str = url_.substr(cpos); + port_ = GetPort(port_str); } else { - host_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); + host_ = url_.substr(cpos); } return; } if (is_port) { - port_ = - static_cast(std::stoi(std::string(url_.begin() + cpos, url_.begin() + pos))); + auto port_str = url_.substr(cpos, pos - cpos); + port_ = GetPort(port_str); } else { - host_ = std::string(url_.begin() + cpos, url_.begin() + pos); + host_ = url_.substr(cpos, pos - cpos); } cpos = pos; @@ -113,21 +119,20 @@ class UrlParser pos = url_.find('?', cpos); if (pos == std::string::npos) { - path_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); - query_ = ""; + path_ = url_.substr(cpos); } else { - path_ = std::string(url_.begin() + cpos, url_.begin() + pos); + path_ = url_.substr(cpos, pos - cpos); cpos = pos + 1; - query_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); + query_ = url_.substr(cpos); } return; } path_ = std::string("/"); if (url_[cpos] == '?') { - query_ = std::string(url_.begin() + cpos, url_.begin() + url_.length()); + query_ = url_.substr(cpos); } } @@ -164,6 +169,20 @@ class UrlParser return std::string::npos; } + + std::uint16_t GetPort(const std::string &s) + { + char *e = nullptr; + errno = 0; + auto port = std::strtol(s.c_str(), &e, 10); + if (e == s.c_str() || e != s.c_str() + s.size() || errno == ERANGE || port < 0 || port > 65535) + { + success_ = false; + return 0; + } + + return static_cast(port); + } }; class UrlDecoder @@ -174,36 +193,39 @@ class UrlDecoder std::string result; result.reserve(encoded.size()); + auto hex_to_int = [](int ch) -> int { + if (ch >= '0' && ch <= '9') + return ch - '0'; + if (ch >= 'a' && ch <= 'f') + return ch - 'a' + 10; + if (ch >= 'A' && ch <= 'F') + return ch - 'A' + 10; + return -1; + }; + for (size_t pos = 0; pos < encoded.size(); pos++) { - if (encoded[pos] == '%') + auto c = encoded[pos]; + if (c == '%') { - - // Invalid input: less than two characters left after '%' - if (encoded.size() < pos + 3) + if (pos + 2 >= encoded.size()) { return encoded; } - char hex[3] = {0}; - hex[0] = encoded[++pos]; - hex[1] = encoded[++pos]; - - char *endptr; - long value = strtol(hex, &endptr, 16); + int hi = hex_to_int(encoded[pos + 1]); + int lo = hex_to_int(encoded[pos + 2]); - // Invalid input: no valid hex characters after '%' - if (endptr != &hex[2]) + if (hi == -1 || lo == -1) { return encoded; } - result.push_back(static_cast(value)); - } - else - { - result.push_back(encoded[pos]); + c = static_cast((hi << 4) | lo); + pos += 2; } + + result.push_back(c); } return result; diff --git a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/server/http_server.h b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/server/http_server.h index 5ea7debc43a..21efac94e0a 100644 --- a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/server/http_server.h +++ b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/server/http_server.h @@ -648,7 +648,15 @@ class HttpServer : private SocketTools::Reactor::SocketCallback { ptr++; } - conn.request.headers[name] = std::string(begin, ptr); + if (!conn.request.headers[name].empty()) + { + conn.request.headers[name] = + conn.request.headers[name].append(",").append(std::string(begin, ptr)); + } + else + { + conn.request.headers[name] = std::string(begin, ptr); + } if (*ptr == '\r') { ptr++; diff --git a/deps/opentelemetry-cpp/ext/src/http/client/curl/CMakeLists.txt b/deps/opentelemetry-cpp/ext/src/http/client/curl/CMakeLists.txt index 6a69c7de51d..c812fcefbf9 100644 --- a/deps/opentelemetry-cpp/ext/src/http/client/curl/CMakeLists.txt +++ b/deps/opentelemetry-cpp/ext/src/http/client/curl/CMakeLists.txt @@ -24,6 +24,11 @@ else() PRIVATE ${CURL_LIBRARIES}) endif() +if(WITH_CURL_LOGGING) + target_compile_definitions(opentelemetry_http_client_curl + PRIVATE ENABLE_CURL_LOGGING) +endif() + if(WITH_OTLP_HTTP_COMPRESSION) if(TARGET ZLIB::ZLIB) target_link_libraries( diff --git a/deps/opentelemetry-cpp/ext/src/http/client/curl/http_client_curl.cc b/deps/opentelemetry-cpp/ext/src/http/client/curl/http_client_curl.cc index 22f20fb0e08..6827b9f9c74 100644 --- a/deps/opentelemetry-cpp/ext/src/http/client/curl/http_client_curl.cc +++ b/deps/opentelemetry-cpp/ext/src/http/client/curl/http_client_curl.cc @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include "opentelemetry/version.h" #ifdef ENABLE_OTLP_COMPRESSION_PREVIEW +# include # include #else # include "opentelemetry/sdk/common/global_log_handler.h" @@ -116,10 +116,10 @@ void Session::SendRequest( #endif } - curl_operation_.reset(new HttpOperation(http_request_->method_, url, http_request_->ssl_options_, - callback_ptr, http_request_->headers_, - http_request_->body_, http_request_->compression_, false, - http_request_->timeout_ms_, reuse_connection)); + curl_operation_.reset(new HttpOperation( + http_request_->method_, url, http_request_->ssl_options_, callback_ptr, + http_request_->headers_, http_request_->body_, http_request_->compression_, false, + http_request_->timeout_ms_, reuse_connection, http_request_->is_log_enabled_)); bool success = CURLE_OK == curl_operation_->SendAsync(this, [this, callback](HttpOperation &operation) { if (operation.WasAborted()) diff --git a/deps/opentelemetry-cpp/ext/src/http/client/curl/http_operation_curl.cc b/deps/opentelemetry-cpp/ext/src/http/client/curl/http_operation_curl.cc index 4de014fd821..b80624d0697 100644 --- a/deps/opentelemetry-cpp/ext/src/http/client/curl/http_operation_curl.cc +++ b/deps/opentelemetry-cpp/ext/src/http/client/curl/http_operation_curl.cc @@ -22,6 +22,7 @@ #include "opentelemetry/ext/http/client/curl/http_client_curl.h" #include "opentelemetry/ext/http/client/curl/http_operation_curl.h" #include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/version.h" @@ -261,7 +262,8 @@ HttpOperation::HttpOperation(opentelemetry::ext::http::client::Method method, // Default connectivity and response size options bool is_raw_response, std::chrono::milliseconds http_conn_timeout, - bool reuse_connection) + bool reuse_connection, + bool is_log_enabled) : is_aborted_(false), is_finished_(false), is_cleaned_(false), @@ -281,6 +283,7 @@ HttpOperation::HttpOperation(opentelemetry::ext::http::client::Method method, request_nwrite_(0), session_state_(opentelemetry::ext::http::client::SessionState::Created), compression_(compression), + is_log_enabled_(is_log_enabled), response_code_(0) { /* get a curl handle */ @@ -569,8 +572,77 @@ CURLcode HttpOperation::SetCurlOffOption(CURLoption option, curl_off_t value) return rc; } +int HttpOperation::CurlLoggerCallback(const CURL * /* handle */, + curl_infotype type, + const char *data, + size_t size, + void * /* clientp */) noexcept +{ + nostd::string_view text_to_log{data, size}; + + if (!text_to_log.empty() && text_to_log[size - 1] == '\n') + { + text_to_log = text_to_log.substr(0, size - 1); + } + + if (type == CURLINFO_TEXT) + { + static const auto kTlsInfo = nostd::string_view("SSL connection using"); + static const auto kFailureMsg = nostd::string_view("Recv failure:"); + + if (text_to_log.substr(0, kTlsInfo.size()) == kTlsInfo) + { + OTEL_INTERNAL_LOG_INFO(text_to_log); + } + else if (text_to_log.substr(0, kFailureMsg.size()) == kFailureMsg) + { + OTEL_INTERNAL_LOG_ERROR(text_to_log); + } +// This guard serves as a catch-all block for all other less interesting output that should +// remain available for maintainer internal use and for debugging purposes only. +#ifdef OTEL_CURL_DEBUG + else + { + OTEL_INTERNAL_LOG_DEBUG(text_to_log); + } +#endif // OTEL_CURL_DEBUG + } +// Same as above, this guard is meant only for internal use by maintainers, and should not be used +// in production (information leak). +#ifdef OTEL_CURL_DEBUG + else if (type == CURLINFO_HEADER_OUT) + { + static const auto kHeaderSent = nostd::string_view("Send header => "); + + while (!text_to_log.empty() && !std::iscntrl(text_to_log[0])) + { + const auto pos = text_to_log.find('\n'); + + if (pos != nostd::string_view::npos) + { + OTEL_INTERNAL_LOG_DEBUG(kHeaderSent << text_to_log.substr(0, pos - 1)); + text_to_log = text_to_log.substr(pos + 1); + } + } + } + else if (type == CURLINFO_HEADER_IN) + { + static const auto kHeaderRecv = nostd::string_view("Recv header => "); + OTEL_INTERNAL_LOG_DEBUG(kHeaderRecv << text_to_log); + } +#endif // OTEL_CURL_DEBUG + + return 0; +} + CURLcode HttpOperation::Setup() { +#ifdef ENABLE_CURL_LOGGING + static constexpr auto kEnableCurlLogging = true; +#else + static constexpr auto kEnableCurlLogging = false; +#endif // ENABLE_CURL_LOGGING + if (!curl_resource_.easy_handle) { return CURLE_FAILED_INIT; @@ -581,11 +653,28 @@ CURLcode HttpOperation::Setup() curl_error_message_[0] = '\0'; curl_easy_setopt(curl_resource_.easy_handle, CURLOPT_ERRORBUFFER, curl_error_message_); +// Support for custom debug function callback was added in version 7.9.6 so we guard against +// exposing the default CURL output by keeping verbosity always disabled in lower versions. +#if LIBCURL_VERSION_NUM < CURL_VERSION_BITS(7, 9, 6) rc = SetCurlLongOption(CURLOPT_VERBOSE, 0L); if (rc != CURLE_OK) { return rc; } +#else + rc = SetCurlLongOption(CURLOPT_VERBOSE, (is_log_enabled_ && kEnableCurlLogging) ? 1L : 0L); + if (rc != CURLE_OK) + { + return rc; + } + + rc = SetCurlPtrOption(CURLOPT_DEBUGFUNCTION, + reinterpret_cast(&HttpOperation::CurlLoggerCallback)); + if (rc != CURLE_OK) + { + return rc; + } +#endif // Specify target URL rc = SetCurlStrOption(CURLOPT_URL, url_.c_str()); diff --git a/deps/opentelemetry-cpp/ext/test/CMakeLists.txt b/deps/opentelemetry-cpp/ext/test/CMakeLists.txt index cc3d4cd1e16..4dabab38218 100644 --- a/deps/opentelemetry-cpp/ext/test/CMakeLists.txt +++ b/deps/opentelemetry-cpp/ext/test/CMakeLists.txt @@ -3,5 +3,5 @@ add_subdirectory(http) if(BUILD_W3CTRACECONTEXT_TEST) - add_subdirectory(w3c_tracecontext_test) + add_subdirectory(w3c_tracecontext_http_test_server) endif() diff --git a/deps/opentelemetry-cpp/ext/test/http/CMakeLists.txt b/deps/opentelemetry-cpp/ext/test/http/CMakeLists.txt index 328f78638b5..9f5514d07bf 100644 --- a/deps/opentelemetry-cpp/ext/test/http/CMakeLists.txt +++ b/deps/opentelemetry-cpp/ext/test/http/CMakeLists.txt @@ -5,7 +5,7 @@ if(WITH_HTTP_CLIENT_CURL) set(FILENAME curl_http_test) add_compile_definitions(WITH_CURL) add_executable(${FILENAME} ${FILENAME}.cc) - target_link_libraries(${FILENAME} ${GTEST_BOTH_LIBRARIES} + target_link_libraries(${FILENAME} ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) if(TARGET CURL::libcurl) @@ -24,8 +24,8 @@ endif() set(URL_PARSER_FILENAME url_parser_test) add_executable(${URL_PARSER_FILENAME} ${URL_PARSER_FILENAME}.cc) -target_link_libraries(${URL_PARSER_FILENAME} ${GTEST_BOTH_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +target_link_libraries(${URL_PARSER_FILENAME} opentelemetry_api ${GMOCK_LIB} + ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) gtest_add_tests( TARGET ${URL_PARSER_FILENAME} TEST_PREFIX ext.http.urlparser. diff --git a/deps/opentelemetry-cpp/ext/test/http/url_parser_test.cc b/deps/opentelemetry-cpp/ext/test/http/url_parser_test.cc index aceb43966af..680e73670fc 100644 --- a/deps/opentelemetry-cpp/ext/test/http/url_parser_test.cc +++ b/deps/opentelemetry-cpp/ext/test/http/url_parser_test.cc @@ -2,212 +2,136 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include -#include +#include #include "opentelemetry/ext/http/common/url_parser.h" namespace http_common = opentelemetry::ext::http::common; -inline const char *BoolToString(bool b) +struct ParsedUrl { - return b ? "true" : "false"; -} + std::string scheme; + std::string host; + std::uint16_t port; + std::string path; + std::string query; + bool success; -TEST(UrlParserTests, BasicTests) -{ - std::map> urls_map{ - {"www.abc.com", - {{"host", "www.abc.com"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"http://www.abc.com", - {{"host", "www.abc.com"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com", - {{"host", "www.abc.com"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com:4431", - {{"host", "www.abc.com"}, - {"port", "4431"}, - {"scheme", "https"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com:4431", - {{"host", "www.abc.com"}, - {"port", "4431"}, - {"scheme", "https"}, - {"path", "/"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com:4431/path1", - {{"host", "www.abc.com"}, - {"port", "4431"}, - {"scheme", "https"}, - {"path", "/path1"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com:4431/path1/path2", - {{"host", "www.abc.com"}, - {"port", "4431"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", ""}, - {"success", "true"}}}, - {"https://www.abc.com/path1/path2", - {{"host", "www.abc.com"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", ""}, - {"success", "true"}}}, - {"http://www.abc.com/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://www.abc.com:8080/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"www.abc.com:8080/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://user:password@www.abc.com:8080/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"user:password@www.abc.com:8080/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"https://user@www.abc.com/path1/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://www.abc.com/path1@bbb/path2?q1=a1&q2=a2", - {{"host", "www.abc.com"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1@bbb/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://1.2.3.4/path1/path2?q1=a1&q2=a2", - {{"host", "1.2.3.4"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"user:password@1.2.3.4:8080/path1/path2?q1=a1&q2=a2", - {{"host", "1.2.3.4"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"https://user@1.2.3.4/path1/path2?q1=a1&q2=a2", - {{"host", "1.2.3.4"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://1.2.3.4/path1@bbb/path2?q1=a1&q2=a2", - {{"host", "1.2.3.4"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1@bbb/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", - {{"host", "[fe80::225:93da:bfde:b5f5]"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"user:password@[fe80::225:93da:bfde:b5f5]:8080/path1/path2?q1=a1&q2=a2", - {{"host", "[fe80::225:93da:bfde:b5f5]"}, - {"port", "8080"}, - {"scheme", "http"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"https://user@[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", - {{"host", "[fe80::225:93da:bfde:b5f5]"}, - {"port", "443"}, - {"scheme", "https"}, - {"path", "/path1/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - {"http://[fe80::225:93da:bfde:b5f5]/path1@bbb/path2?q1=a1&q2=a2", - {{"host", "[fe80::225:93da:bfde:b5f5]"}, - {"port", "80"}, - {"scheme", "http"}, - {"path", "/path1@bbb/path2"}, - {"query", "q1=a1&q2=a2"}, - {"success", "true"}}}, - }; - for (auto &url_map : urls_map) + friend void PrintTo(const ParsedUrl &p, std::ostream *os) { - http_common::UrlParser url(url_map.first); - auto url_properties = url_map.second; - ASSERT_EQ(BoolToString(url.success_), url_properties["success"]); - ASSERT_EQ(url.host_, url_properties["host"]); - ASSERT_EQ(std::to_string(url.port_), url_properties["port"]); - ASSERT_EQ(url.scheme_, url_properties["scheme"]); - ASSERT_EQ(url.path_, url_properties["path"]); - ASSERT_EQ(url.query_, url_properties["query"]); + *os << "(valid: " << (p.success ? "yes" : "no") << ", scheme: " << p.scheme + << ", host: " << p.host << ", port: " << p.port << ", path: " << p.path + << ", query: " << p.query << ")"; } +}; + +class UrlParserTests : public testing::TestWithParam> +{}; + +INSTANTIATE_TEST_SUITE_P( + SampleValues, + UrlParserTests, + testing::Values( + std::make_tuple("www.abc.com", ParsedUrl{"http", "www.abc.com", 80, "/", "", true}), + std::make_tuple("http://www.abc.com", ParsedUrl{"http", "www.abc.com", 80, "/", "", true}), + std::make_tuple("https://www.abc.com", + ParsedUrl{"https", "www.abc.com", 443, "/", "", true}), + std::make_tuple("https://www.abc.com:4431", + ParsedUrl{"https", "www.abc.com", 4431, "/", "", true}), + std::make_tuple("https://www.abc.com:4431/path1", + ParsedUrl{"https", "www.abc.com", 4431, "/path1", "", true}), + std::make_tuple("https://www.abc.com:4431/path1/path2", + ParsedUrl{"https", "www.abc.com", 4431, "/path1/path2", "", true}), + std::make_tuple("https://www.abc.com/path1/path2", + ParsedUrl{"https", "www.abc.com", 443, "/path1/path2", "", true}), + std::make_tuple("http://www.abc.com/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 80, "/path1/path2", "q1=a1&q2=a2", true}), + std::make_tuple("http://www.abc.com:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 8080, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("www.abc.com:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 8080, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("http://user:password@www.abc.com:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 8080, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("user:password@www.abc.com:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 8080, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("https://user@www.abc.com/path1/path2?q1=a1&q2=a2", + ParsedUrl{"https", "www.abc.com", 443, "/path1/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("http://www.abc.com/path1@bbb/path2?q1=a1&q2=a2", + ParsedUrl{"http", "www.abc.com", 80, "/path1@bbb/path2", "q1=a1&q2=a2", + true}), + std::make_tuple("http://1.2.3.4/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "1.2.3.4", 80, "/path1/path2", "q1=a1&q2=a2", true}), + std::make_tuple("user:password@1.2.3.4:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "1.2.3.4", 8080, "/path1/path2", "q1=a1&q2=a2", true}), + std::make_tuple("https://user@1.2.3.4/path1/path2?q1=a1&q2=a2", + ParsedUrl{"https", "1.2.3.4", 443, "/path1/path2", "q1=a1&q2=a2", true}), + std::make_tuple("http://1.2.3.4/path1@bbb/path2?q1=a1&q2=a2", + ParsedUrl{"http", "1.2.3.4", 80, "/path1@bbb/path2", "q1=a1&q2=a2", true}), + std::make_tuple("http://[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "[fe80::225:93da:bfde:b5f5]", 80, "/path1/path2", + "q1=a1&q2=a2", true}), + std::make_tuple("user:password@[fe80::225:93da:bfde:b5f5]:8080/path1/path2?q1=a1&q2=a2", + ParsedUrl{"http", "[fe80::225:93da:bfde:b5f5]", 8080, "/path1/path2", + "q1=a1&q2=a2", true}), + std::make_tuple("https://user@[fe80::225:93da:bfde:b5f5]/path1/path2?q1=a1&q2=a2", + ParsedUrl{"https", "[fe80::225:93da:bfde:b5f5]", 443, "/path1/path2", + "q1=a1&q2=a2", true}), + std::make_tuple("http://[fe80::225:93da:bfde:b5f5]/path1@bbb/path2?q1=a1&q2=a2", + ParsedUrl{"http", "[fe80::225:93da:bfde:b5f5]", 80, "/path1@bbb/path2", + "q1=a1&q2=a2", true}), + std::make_tuple("https://https://example.com/some/path", + ParsedUrl{"https", "https", 0, "//example.com/some/path", "", false}), + std::make_tuple("https://example.com:-1/some/path", + ParsedUrl{"https", "example.com", 0, "/some/path", "", false}), + std::make_tuple("https://example.com:65536/some/path", + ParsedUrl{"https", "example.com", 0, "/some/path", "", false}), + std::make_tuple("https://example.com:80a/some/path", + ParsedUrl{"https", "example.com", 0, "/some/path", "", false}), + std::make_tuple("https://example.com:18446744073709551616/some/path", + ParsedUrl{"https", "example.com", 0, "/some/path", "", false}))); + +TEST_P(UrlParserTests, BasicTests) +{ + const auto &url = std::get<0>(GetParam()); + const auto &expected = std::get<1>(GetParam()); + + const auto actual = http_common::UrlParser(url); + + EXPECT_EQ(actual.success_, expected.success); + EXPECT_EQ(actual.host_, expected.host); + EXPECT_EQ(actual.port_, expected.port); + EXPECT_EQ(actual.scheme_, expected.scheme); + EXPECT_EQ(actual.path_, expected.path); + EXPECT_EQ(actual.query_, expected.query); } -TEST(UrlDecoderTests, BasicTests) +class UrlDecoderTests : public ::testing::TestWithParam> +{}; + +INSTANTIATE_TEST_SUITE_P( + SampleValues, + UrlDecoderTests, + testing::Values(std::make_tuple("Authentication=Basic xxx", "Authentication=Basic xxx"), + std::make_tuple("Authentication=Basic%20xxx", "Authentication=Basic xxx"), + std::make_tuple("%C3%B6%C3%A0%C2%A7%C3%96abcd%C3%84", + "\xc3\xb6\xc3\xa0\xc2\xa7\xc3\x96\x61\x62\x63\x64\xc3\x84"), + std::make_tuple("%2x", "%2x"), + std::make_tuple("%20", " "), + std::make_tuple("text%2", "text%2"), + std::make_tuple("%20test%zztest", "%20test%zztest"), + std::make_tuple("%20test%2", "%20test%2"))); + +TEST_P(UrlDecoderTests, BasicTests) { - std::map testdata{ - {"Authentication=Basic xxx", "Authentication=Basic xxx"}, - {"Authentication=Basic%20xxx", "Authentication=Basic xxx"}, - {"%C3%B6%C3%A0%C2%A7%C3%96abcd%C3%84", - "\xc3\xb6\xc3\xa0\xc2\xa7\xc3\x96\x61\x62\x63\x64\xc3\x84"}, - {"%2x", "%2x"}, - {"%20", " "}, - {"text%2", "text%2"}, - }; + const auto &encoded = std::get<0>(GetParam()); + const auto &expected = std::get<1>(GetParam()); + const auto actual = http_common::UrlDecoder::Decode(encoded); - for (auto &testsample : testdata) - { - ASSERT_EQ(http_common::UrlDecoder::Decode(testsample.first), testsample.second); - ASSERT_TRUE(http_common::UrlDecoder::Decode(testsample.first) == testsample.second); - } + EXPECT_EQ(actual, expected); } diff --git a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/BUILD b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/BUILD similarity index 92% rename from deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/BUILD rename to deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/BUILD index c67ab11a9cf..8c1c8c17e97 100644 --- a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/BUILD +++ b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/BUILD @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 cc_binary( - name = "w3c_tracecontext_test", + name = "w3c_tracecontext_http_test_server", srcs = [ "main.cc", ], diff --git a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/CMakeLists.txt b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt similarity index 66% rename from deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/CMakeLists.txt rename to deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt index cc2ae43b1cb..85e3c3eea0c 100644 --- a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/CMakeLists.txt +++ b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt @@ -3,12 +3,13 @@ include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include) -add_executable(w3c_tracecontext_test main.cc) +add_executable(w3c_tracecontext_http_test_server main.cc) target_link_libraries( - w3c_tracecontext_test + w3c_tracecontext_http_test_server PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace opentelemetry_http_client_curl opentelemetry_exporter_ostream_span ${CURL_LIBRARIES} nlohmann_json::nlohmann_json) if(nlohmann_json_clone) - add_dependencies(w3c_tracecontext_test nlohmann_json::nlohmann_json) + add_dependencies(w3c_tracecontext_http_test_server + nlohmann_json::nlohmann_json) endif() diff --git a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/Dockerfile b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/Dockerfile similarity index 100% rename from deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/Dockerfile rename to deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/Dockerfile diff --git a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/README.md b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/README.md similarity index 80% rename from deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/README.md rename to deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/README.md index 8eda092f825..afe2a68638a 100644 --- a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/README.md +++ b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/README.md @@ -3,7 +3,7 @@ This test application is intended to be used as a test service for the [W3C Distributed Tracing Validation Service](https://github.com/w3c/trace-context/tree/master/test). It is -implemented according to [this +implemented according to [these instructions](https://github.com/w3c/trace-context/tree/master/test#implement-test-service). ## Usage @@ -11,7 +11,7 @@ instructions](https://github.com/w3c/trace-context/tree/master/test#implement-te 1: Build and start the test service endpoint: ```sh -./w3c_tracecontext_test +./w3c_tracecontext_http_test_server Listening to http://localhost:30000/test ``` @@ -19,7 +19,7 @@ Listening to http://localhost:30000/test A custom port number for the test service to listen to can be specified: ```sh -./w3c_tracecontext_test 31339 +./w3c_tracecontext_http_test_server 31339 Listening to http://localhost:31339/test ``` @@ -47,4 +47,9 @@ docker run --network host w3c_driver http://localhost:31339/test 3: The validation service will run the test suite and print detailed test results. -4: Stop the test service by pressing enter. +4: Stop the test service by invoking `/stop`. Make sure to use the correct port number. + +```sh +# Assuming the service is currently running at port 30000 +curl http://localhost:30000/stop +``` diff --git a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/main.cc b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/main.cc similarity index 86% rename from deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/main.cc rename to deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/main.cc index fed07a23985..5af8c141de9 100644 --- a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_test/main.cc +++ b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/main.cc @@ -3,8 +3,6 @@ #include #include -#include -#include #include #include #include @@ -12,19 +10,16 @@ #include #include -#include "opentelemetry/context/context_value.h" #include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/exporters/ostream/span_exporter.h" #include "opentelemetry/ext/http/client/curl/http_client_curl.h" -#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" #include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/ext/http/server/http_server.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" -#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/simple_processor.h" #include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/sdk/trace/tracer_provider.h" @@ -45,16 +40,34 @@ namespace { static trace_api::propagation::HttpTraceContext propagator_format; +static bool equalsIgnoreCase(const std::string &str1, const std::string &str2) +{ + if (str1.length() != str2.length()) + { + return false; + } + for (size_t i = 0; i < str1.length(); i++) + { + if (tolower(str1[i]) != tolower(str2[i])) + { + return false; + } + } + return true; +} + class TextMapCarrierTest : public context::propagation::TextMapCarrier { public: TextMapCarrierTest(std::map &headers) : headers_(headers) {} nostd::string_view Get(nostd::string_view key) const noexcept override { - auto it = headers_.find(std::string(key)); - if (it != headers_.end()) + for (const auto &elem : headers_) { - return nostd::string_view(it->second); + if (equalsIgnoreCase(elem.first, std::string(key))) + { + return nostd::string_view(elem.second); + } } return ""; } @@ -85,7 +98,7 @@ void initTracer() nostd::shared_ptr get_tracer() { auto provider = trace_api::Provider::GetTracerProvider(); - return provider->GetTracer("w3c_tracecontext_test"); + return provider->GetTracer("w3c_tracecontext_http_test_server"); } struct Uri @@ -161,6 +174,7 @@ int main(int argc, char *argv[]) constexpr char default_host[] = "localhost"; constexpr uint16_t default_port = 30000; uint16_t port; + std::atomic_bool stop_server(false); // The port the validation service listens to can be specified via the command line. if (argc > 1) @@ -207,16 +221,28 @@ int main(int argc, char *argv[]) return 0; }}; + testing::HttpRequestCallback stop_cb{ + [&](testing::HttpRequest const & /*req*/, testing::HttpResponse &resp) { + std::cout << "Received request to stop server \n"; + stop_server.store(true); + resp.code = 200; + return 0; + }}; + server["/test"] = test_cb; + server["/stop"] = stop_cb; // Start server server.start(); std::cout << "Listening at http://" << default_host << ":" << port << "/test\n"; - // Wait for console input - std::cin.get(); - - // Stop server + // Wait for signal to stop server + while (!stop_server.load()) + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + // received signal to stop server + std::cout << "Stopping server \n"; server.stop(); } diff --git a/deps/opentelemetry-cpp/otlp-http-exporter.gyp b/deps/opentelemetry-cpp/otlp-http-exporter.gyp index 44783a73378..3449bd43d8a 100644 --- a/deps/opentelemetry-cpp/otlp-http-exporter.gyp +++ b/deps/opentelemetry-cpp/otlp-http-exporter.gyp @@ -6,6 +6,7 @@ 'sources': [ 'exporters/otlp/src/otlp_environment.cc', 'exporters/otlp/src/otlp_grpc_client.cc', + 'exporters/otlp/src/otlp_grpc_client_factory.cc', 'exporters/otlp/src/otlp_grpc_exporter_options.cc', 'exporters/otlp/src/otlp_grpc_exporter.cc', 'exporters/otlp/src/otlp_grpc_log_record_exporter.cc', diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/empty_attributes.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/empty_attributes.h index 0afe439ee62..4a699e7d32b 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/empty_attributes.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/empty_attributes.h @@ -21,12 +21,12 @@ namespace sdk * with default attributes. */ static const opentelemetry::common::KeyValueIterableView< - std::array, 0>> & + std::array, 0>> & GetEmptyAttributes() noexcept { - static const std::array, 0> array{}; + static const std::array, 0> array{}; static const opentelemetry::common::KeyValueIterableView< - std::array, 0>> + std::array, 0>> kEmptyAttributes(array); return kEmptyAttributes; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h index 1d14c0760e5..91fc503ff06 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h @@ -180,6 +180,7 @@ class DefaultAggregation return AggregationType::kSum; case InstrumentType::kHistogram: return AggregationType::kHistogram; + case InstrumentType::kGauge: case InstrumentType::kObservableGauge: return AggregationType::kLastValue; case InstrumentType::kSummary: diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/instruments.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/instruments.h index eb9fc30a5a4..0d6b5e253d2 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/instruments.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/instruments.h @@ -22,6 +22,7 @@ enum class InstrumentType kObservableCounter, kObservableGauge, kObservableUpDownCounter, + kGauge, kSummary }; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/meter.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/meter.h index b29bede0124..2e9153e1511 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/meter.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/meter.h @@ -75,6 +75,18 @@ class Meter final : public opentelemetry::metrics::Meter nostd::string_view description = "", nostd::string_view unit = "") noexcept override; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::unique_ptr> CreateInt64Gauge( + nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept override; + + nostd::unique_ptr> CreateDoubleGauge( + nostd::string_view name, + nostd::string_view description = "", + nostd::string_view unit = "") noexcept override; +#endif + nostd::shared_ptr CreateInt64ObservableGauge( nostd::string_view name, nostd::string_view description = "", diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h index 039a37e7485..ff5eaeb2829 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h @@ -100,6 +100,40 @@ class DoubleUpDownCounter : public Synchronous, public opentelemetry::metrics::U void Add(double value, const opentelemetry::context::Context &context) noexcept override; }; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +class LongGauge : public Synchronous, public opentelemetry::metrics::Gauge +{ +public: + LongGauge(const InstrumentDescriptor &instrument_descriptor, + std::unique_ptr storage); + + void Record(int64_t value, + const opentelemetry::common::KeyValueIterable &attributes) noexcept override; + void Record(int64_t value, + const opentelemetry::common::KeyValueIterable &attributes, + const opentelemetry::context::Context &context) noexcept override; + + void Record(int64_t value) noexcept override; + void Record(int64_t value, const opentelemetry::context::Context &context) noexcept override; +}; + +class DoubleGauge : public Synchronous, public opentelemetry::metrics::Gauge +{ +public: + DoubleGauge(const InstrumentDescriptor &instrument_descriptor, + std::unique_ptr storage); + + void Record(double value, + const opentelemetry::common::KeyValueIterable &attributes) noexcept override; + void Record(double value, + const opentelemetry::common::KeyValueIterable &attributes, + const opentelemetry::context::Context &context) noexcept override; + + void Record(double value) noexcept override; + void Record(double value, const opentelemetry::context::Context &context) noexcept override; +}; +#endif + class LongHistogram : public Synchronous, public opentelemetry::metrics::Histogram { public: diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h index 9ff985be4de..1c11ba68f9d 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h @@ -4,9 +4,13 @@ */ /* - DO NOT EDIT, this is an Auto-generated file - from buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 -*/ + * This file is DEPRECATED, and no longer updated. + * See file DEPRECATED.md for details. + */ + +#ifdef OPENTELEMETRY_NO_DEPRECATED_CODE +# error "header is deprecated." +#endif #pragma once diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/span_data.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/span_data.h index 2bd8b2112bb..96b8e5deee7 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -257,7 +257,7 @@ class SpanData final : public Recordable opentelemetry::common::SystemTimestamp timestamp = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), const opentelemetry::common::KeyValueIterable &attributes = - opentelemetry::common::KeyValueIterableView>( + opentelemetry::common::KeyValueIterableView>( {})) noexcept override { SpanDataEvent event(std::string(name), timestamp, attributes); diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h index b8f4c076f17..387eb64fab6 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.17.0" +#define OPENTELEMETRY_SDK_VERSION "1.18.0" #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/sdk/src/common/CMakeLists.txt b/deps/opentelemetry-cpp/sdk/src/common/CMakeLists.txt index 664db38e17c..16229e08207 100644 --- a/deps/opentelemetry-cpp/sdk/src/common/CMakeLists.txt +++ b/deps/opentelemetry-cpp/sdk/src/common/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries( opentelemetry_common PUBLIC opentelemetry_api opentelemetry_sdk Threads::Threads) -if(WITH_ABSEIL) +if(WITH_ABSEIL OR WITH_OTLP_GRPC) target_link_libraries(opentelemetry_common PUBLIC absl::strings) endif() diff --git a/deps/opentelemetry-cpp/sdk/src/logs/BUILD b/deps/opentelemetry-cpp/sdk/src/logs/BUILD index f1a0828527c..93642e99b61 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/BUILD +++ b/deps/opentelemetry-cpp/sdk/src/logs/BUILD @@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "logs", srcs = glob(["**/*.cc"]), - hdrs = glob(["**/*.h"]), include_prefix = "src/logs", deps = [ "//api", diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/BUILD b/deps/opentelemetry-cpp/sdk/src/metrics/BUILD index ff8d244da19..78f224b5aba 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/BUILD +++ b/deps/opentelemetry-cpp/sdk/src/metrics/BUILD @@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "metrics", srcs = glob(["**/*.cc"]), - hdrs = glob(["**/*.h"]), include_prefix = "src/metrics", deps = [ "//api", diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/meter.cc b/deps/opentelemetry-cpp/sdk/src/metrics/meter.cc index c61f3a8d316..6d09f264dba 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/meter.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/meter.cc @@ -186,6 +186,50 @@ opentelemetry::nostd::unique_ptr> Meter::CreateDouble new DoubleHistogram(instrument_descriptor, std::move(storage))}; } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +opentelemetry::nostd::unique_ptr> Meter::CreateInt64Gauge( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept +{ + if (!ValidateInstrument(name, description, unit)) + { + OTEL_INTERNAL_LOG_ERROR("Meter::CreateInt64Gauge - failed. Invalid parameters." + << name << " " << description << " " << unit + << ". Measurements won't be recorded."); + return opentelemetry::nostd::unique_ptr>( + new metrics::NoopGauge(name, description, unit)); + } + InstrumentDescriptor instrument_descriptor = { + std::string{name.data(), name.size()}, std::string{description.data(), description.size()}, + std::string{unit.data(), unit.size()}, InstrumentType::kGauge, InstrumentValueType::kLong}; + auto storage = RegisterSyncMetricStorage(instrument_descriptor); + return opentelemetry::nostd::unique_ptr>{ + new LongGauge(instrument_descriptor, std::move(storage))}; +} + +opentelemetry::nostd::unique_ptr> Meter::CreateDoubleGauge( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept +{ + if (!ValidateInstrument(name, description, unit)) + { + OTEL_INTERNAL_LOG_ERROR("Meter::CreateDoubleGauge - failed. Invalid parameters." + << name << " " << description << " " << unit + << ". Measurements won't be recorded."); + return opentelemetry::nostd::unique_ptr>( + new metrics::NoopGauge(name, description, unit)); + } + InstrumentDescriptor instrument_descriptor = { + std::string{name.data(), name.size()}, std::string{description.data(), description.size()}, + std::string{unit.data(), unit.size()}, InstrumentType::kGauge, InstrumentValueType::kDouble}; + auto storage = RegisterSyncMetricStorage(instrument_descriptor); + return opentelemetry::nostd::unique_ptr>{ + new DoubleGauge(instrument_descriptor, std::move(storage))}; +} +#endif + opentelemetry::nostd::shared_ptr Meter::CreateInt64ObservableGauge(opentelemetry::nostd::string_view name, opentelemetry::nostd::string_view description, diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/state/metric_collector.cc b/deps/opentelemetry-cpp/sdk/src/metrics/state/metric_collector.cc index 2a799b7fda5..35d5e53939c 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/state/metric_collector.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/state/metric_collector.cc @@ -36,7 +36,18 @@ MetricCollector::MetricCollector(opentelemetry::sdk::metrics::MeterContext *cont AggregationTemporality MetricCollector::GetAggregationTemporality( InstrumentType instrument_type) noexcept { - return metric_reader_->GetAggregationTemporality(instrument_type); + auto aggregation_temporality = metric_reader_->GetAggregationTemporality(instrument_type); + if (aggregation_temporality == AggregationTemporality::kDelta && + instrument_type == InstrumentType::kGauge) + { + OTEL_INTERNAL_LOG_ERROR( + "[MetricCollector::GetAggregationTemporality] - Error getting aggregation temporality." + << "Delta temporality for Synchronous Gauge is currently not supported, using cumulative " + "temporality"); + + return AggregationTemporality::kCumulative; + } + return aggregation_temporality; } MetricProducer::Result MetricCollector::Produce() noexcept diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/sync_instruments.cc b/deps/opentelemetry-cpp/sdk/src/metrics/sync_instruments.cc index 56429a079f9..de66e930547 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/sync_instruments.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/sync_instruments.cc @@ -292,6 +292,127 @@ void DoubleUpDownCounter::Add(double value, const opentelemetry::context::Contex return storage_->RecordDouble(value, context); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +LongGauge::LongGauge(const InstrumentDescriptor &instrument_descriptor, + std::unique_ptr storage) + : Synchronous(instrument_descriptor, std::move(storage)) +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_ERROR("[LongGauge::LongGauge] - Error constructing LongGauge." + << "The metric storage is invalid for " << instrument_descriptor.name_); + } +} + +void LongGauge::Record(int64_t value, + const opentelemetry::common::KeyValueIterable &attributes) noexcept +{ + auto context = opentelemetry::context::Context{}; + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,A)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordLong(value, attributes, context); +} + +void LongGauge::Record(int64_t value, + const opentelemetry::common::KeyValueIterable &attributes, + const opentelemetry::context::Context &context) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,A,C)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordLong(value, attributes, context); +} + +void LongGauge::Record(int64_t value) noexcept +{ + auto context = opentelemetry::context::Context{}; + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordLong(value, context); +} + +void LongGauge::Record(int64_t value, const opentelemetry::context::Context &context) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,C)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordLong(value, context); +} + +DoubleGauge::DoubleGauge(const InstrumentDescriptor &instrument_descriptor, + std::unique_ptr storage) + : Synchronous(instrument_descriptor, std::move(storage)) +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_ERROR("[DoubleGauge::DoubleGauge] - Error constructing DoubleUpDownCounter." + << "The metric storage is invalid for " << instrument_descriptor.name_); + } +} + +void DoubleGauge::Record(double value, + const opentelemetry::common::KeyValueIterable &attributes) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,A)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + } + auto context = opentelemetry::context::Context{}; + return storage_->RecordDouble(value, attributes, context); +} + +void DoubleGauge::Record(double value, + const opentelemetry::common::KeyValueIterable &attributes, + const opentelemetry::context::Context &context) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,A,C)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordDouble(value, attributes, context); +} + +void DoubleGauge::Record(double value) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + auto context = opentelemetry::context::Context{}; + return storage_->RecordDouble(value, context); +} + +void DoubleGauge::Record(double value, const opentelemetry::context::Context &context) noexcept +{ + if (!storage_) + { + OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,C)] Value not recorded - invalid storage for: " + << instrument_descriptor_.name_); + return; + } + return storage_->RecordDouble(value, context); +} +#endif + LongHistogram::LongHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) diff --git a/deps/opentelemetry-cpp/sdk/src/resource/BUILD b/deps/opentelemetry-cpp/sdk/src/resource/BUILD index 6cff52723ad..88456299901 100644 --- a/deps/opentelemetry-cpp/sdk/src/resource/BUILD +++ b/deps/opentelemetry-cpp/sdk/src/resource/BUILD @@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "resource", srcs = glob(["**/*.cc"]), - hdrs = glob(["**/*.h"]), include_prefix = "src/resource", deps = [ "//api", diff --git a/deps/opentelemetry-cpp/sdk/src/resource/resource.cc b/deps/opentelemetry-cpp/sdk/src/resource/resource.cc index 919624686d8..5ae5446e805 100644 --- a/deps/opentelemetry-cpp/sdk/src/resource/resource.cc +++ b/deps/opentelemetry-cpp/sdk/src/resource/resource.cc @@ -8,8 +8,10 @@ #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/resource/resource_detector.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" #include "opentelemetry/sdk/version/version.h" +#include "opentelemetry/semconv/incubating/process_attributes.h" +#include "opentelemetry/semconv/service_attributes.h" +#include "opentelemetry/semconv/telemetry_attributes.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -36,16 +38,16 @@ Resource Resource::Create(const ResourceAttributes &attributes, const std::strin auto resource = Resource::GetDefault().Merge(otel_resource).Merge(Resource{attributes, schema_url}); - if (resource.attributes_.find(SemanticConventions::kServiceName) == resource.attributes_.end()) + if (resource.attributes_.find(semconv::service::kServiceName) == resource.attributes_.end()) { std::string default_service_name = "unknown_service"; auto it_process_executable_name = - resource.attributes_.find(SemanticConventions::kProcessExecutableName); + resource.attributes_.find(semconv::process::kProcessExecutableName); if (it_process_executable_name != resource.attributes_.end()) { default_service_name += ":" + nostd::get(it_process_executable_name->second); } - resource.attributes_[SemanticConventions::kServiceName] = default_service_name; + resource.attributes_[semconv::service::kServiceName] = default_service_name; } return resource; } @@ -59,9 +61,9 @@ Resource &Resource::GetEmpty() Resource &Resource::GetDefault() { static Resource default_resource( - {{SemanticConventions::kTelemetrySdkLanguage, "cpp"}, - {SemanticConventions::kTelemetrySdkName, "opentelemetry"}, - {SemanticConventions::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}}, + {{semconv::telemetry::kTelemetrySdkLanguage, "cpp"}, + {semconv::telemetry::kTelemetrySdkName, "opentelemetry"}, + {semconv::telemetry::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}}, std::string{}); return default_resource; } diff --git a/deps/opentelemetry-cpp/sdk/src/resource/resource_detector.cc b/deps/opentelemetry-cpp/sdk/src/resource/resource_detector.cc index b7c7c7e6147..cab8ce748ad 100644 --- a/deps/opentelemetry-cpp/sdk/src/resource/resource_detector.cc +++ b/deps/opentelemetry-cpp/sdk/src/resource/resource_detector.cc @@ -4,7 +4,7 @@ #include "opentelemetry/sdk/resource/resource_detector.h" #include "opentelemetry/sdk/common/env_variables.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "opentelemetry/semconv/service_attributes.h" #include "opentelemetry/version.h" #include @@ -55,7 +55,7 @@ Resource OTELResourceDetector::Detect() noexcept if (service_name_exists) { - attributes[SemanticConventions::kServiceName] = service_name; + attributes[semconv::service::kServiceName] = service_name; } return Resource(attributes); diff --git a/deps/opentelemetry-cpp/sdk/src/version/version.cc b/deps/opentelemetry-cpp/sdk/src/version/version.cc index 97e7f15549f..078bafe2ea7 100644 --- a/deps/opentelemetry-cpp/sdk/src/version/version.cc +++ b/deps/opentelemetry-cpp/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 17; +const int minor_version = 18; const int patch_version = 0; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.17.0"; -const char *full_version = "1.17.0-NONE-NONE"; -const char *build_date = "Mon Oct 7 08:55:12 PM UTC 2024"; +const char *short_version = "1.18.0"; +const char *full_version = "1.18.0-NONE-NONE"; +const char *build_date = "Mon Nov 25 08:46:03 PM UTC 2024"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/CMakeLists.txt b/deps/opentelemetry-cpp/sdk/test/metrics/CMakeLists.txt index ccc31de6898..9effa73a4cf 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/CMakeLists.txt +++ b/deps/opentelemetry-cpp/sdk/test/metrics/CMakeLists.txt @@ -19,6 +19,7 @@ foreach( cardinality_limit_test histogram_test sync_metric_storage_counter_test + sync_metric_storage_gauge_test sync_metric_storage_histogram_test sync_metric_storage_up_down_counter_test async_metric_storage_test diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sync_instruments_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sync_instruments_test.cc index fb59e1d0333..22a05988dce 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/sync_instruments_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sync_instruments_test.cc @@ -112,6 +112,45 @@ TEST(SyncInstruments, DoubleUpDownCounter) counter.Add(10.10, opentelemetry::common::KeyValueIterableView({})); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +TEST(SyncInstruments, LongGauge) +{ + InstrumentDescriptor instrument_descriptor = {"long_gauge", "description", "1", + InstrumentType::kGauge, InstrumentValueType::kLong}; + std::unique_ptr metric_storage(new SyncMultiMetricStorage()); + LongGauge gauge(instrument_descriptor, std::move(metric_storage)); + gauge.Record(10); + gauge.Record(10, opentelemetry::context::Context{}); + + gauge.Record(10, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + gauge.Record(10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}})); + gauge.Record(10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); + gauge.Record(10, opentelemetry::common::KeyValueIterableView({})); +} + +TEST(SyncInstruments, DoubleGauge) +{ + InstrumentDescriptor instrument_descriptor = { + "double_gauge", "description", "1", InstrumentType::kGauge, InstrumentValueType::kDouble}; + std::unique_ptr metric_storage(new SyncMultiMetricStorage()); + DoubleGauge gauge(instrument_descriptor, std::move(metric_storage)); + gauge.Record(10.10); + gauge.Record(10.10, opentelemetry::context::Context{}); + + gauge.Record(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + gauge.Record(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}})); + gauge.Record(10.10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); + gauge.Record(10.10, opentelemetry::common::KeyValueIterableView({})); +} +#endif + TEST(SyncInstruments, LongHistogram) { InstrumentDescriptor instrument_descriptor = { diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_gauge_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_gauge_test.cc new file mode 100644 index 00000000000..f826755af36 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_gauge_test.cc @@ -0,0 +1,189 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "common.h" + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" + +#include +#include +#include + +using namespace opentelemetry::sdk::metrics; +using namespace opentelemetry::common; +namespace nostd = opentelemetry::nostd; + +class WritableMetricStorageTestFixture : public ::testing::TestWithParam +{}; + +TEST_P(WritableMetricStorageTestFixture, LongGaugeLastValueAggregation) +{ +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + AggregationTemporality temporality = GetParam(); + auto sdk_start_ts = std::chrono::system_clock::now(); + InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kGauge, + InstrumentValueType::kLong}; + std::map attributes_roomA = {{"Room.id", "Rack A"}}; + std::map attributes_roomB = {{"Room.id", "Rack B"}}; + + std::unique_ptr default_attributes_processor{ + new DefaultAttributesProcessor{}}; + opentelemetry::sdk::metrics::SyncMetricStorage storage( + instr_desc, AggregationType::kLastValue, default_attributes_processor.get(), +# ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW + ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), +# endif + nullptr); + + int64_t bg_noise_level_1_roomA = 10; + int64_t bg_noise_level_1_roomB = 20; + + storage.RecordLong(bg_noise_level_1_roomA, + KeyValueIterableView>(attributes_roomA), + opentelemetry::context::Context{}); + storage.RecordLong(bg_noise_level_1_roomB, + KeyValueIterableView>(attributes_roomB), + opentelemetry::context::Context{}); + + int64_t bg_noise_level_2_roomA = 43; + int64_t bg_noise_level_2_roomB = 25; + + storage.RecordLong(bg_noise_level_2_roomA, + KeyValueIterableView>(attributes_roomA), + opentelemetry::context::Context{}); + storage.RecordLong(bg_noise_level_2_roomB, + KeyValueIterableView>(attributes_roomB), + opentelemetry::context::Context{}); + + std::shared_ptr collector(new MockCollectorHandle(temporality)); + std::vector> collectors; + collectors.push_back(collector); + + // Some computation here + auto collection_ts = std::chrono::system_clock::now(); + size_t count_attributes = 0; + storage.Collect( + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { + for (const auto &data_attr : metric_data.point_data_attr_) + { + auto lastvalue_data = opentelemetry::nostd::get(data_attr.point_data); + if (opentelemetry::nostd::get( + data_attr.attributes.find("Room.id")->second) == "Rack A") + { + if (temporality == AggregationTemporality::kCumulative) + { + EXPECT_EQ(opentelemetry::nostd::get(lastvalue_data.value_), + bg_noise_level_2_roomA); + } + count_attributes++; + } + else if (opentelemetry::nostd::get( + data_attr.attributes.find("Room.id")->second) == "Rack B") + { + if (temporality == AggregationTemporality::kCumulative) + { + EXPECT_EQ(opentelemetry::nostd::get(lastvalue_data.value_), + bg_noise_level_2_roomB); + } + count_attributes++; + } + } + return true; + }); + EXPECT_EQ(count_attributes, 2); // RackA and RackB +#else + EXPECT_TRUE(true); +#endif +} + +INSTANTIATE_TEST_SUITE_P(WritableMetricStorageTestLong, + WritableMetricStorageTestFixture, + ::testing::Values(AggregationTemporality::kCumulative)); + +TEST_P(WritableMetricStorageTestFixture, DoubleGaugeLastValueAggregation) +{ +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + AggregationTemporality temporality = GetParam(); + auto sdk_start_ts = std::chrono::system_clock::now(); + InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kGauge, + InstrumentValueType::kDouble}; + std::map attributes_roomA = {{"Room.id", "Rack A"}}; + std::map attributes_roomB = {{"Room.id", "Rack B"}}; + + std::unique_ptr default_attributes_processor{ + new DefaultAttributesProcessor{}}; + opentelemetry::sdk::metrics::SyncMetricStorage storage( + instr_desc, AggregationType::kLastValue, default_attributes_processor.get(), +# ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW + ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), +# endif + nullptr); + + double bg_noise_level_1_roomA = 4.3; + double bg_noise_level_1_roomB = 2.5; + + storage.RecordDouble(bg_noise_level_1_roomA, + KeyValueIterableView>(attributes_roomA), + opentelemetry::context::Context{}); + storage.RecordDouble(bg_noise_level_1_roomB, + KeyValueIterableView>(attributes_roomB), + opentelemetry::context::Context{}); + + double bg_noise_level_2_roomA = 10.5; + double bg_noise_level_2_roomB = 20.5; + + storage.RecordDouble(bg_noise_level_2_roomA, + KeyValueIterableView>(attributes_roomA), + opentelemetry::context::Context{}); + storage.RecordDouble(bg_noise_level_2_roomB, + KeyValueIterableView>(attributes_roomB), + opentelemetry::context::Context{}); + + std::shared_ptr collector(new MockCollectorHandle(temporality)); + std::vector> collectors; + collectors.push_back(collector); + + // Some computation here + auto collection_ts = std::chrono::system_clock::now(); + size_t count_attributes = 0; + storage.Collect( + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { + for (const auto &data_attr : metric_data.point_data_attr_) + { + auto lastvalue_data = opentelemetry::nostd::get(data_attr.point_data); + if (opentelemetry::nostd::get( + data_attr.attributes.find("Room.id")->second) == "Rack A") + { + if (temporality == AggregationTemporality::kCumulative) + { + EXPECT_DOUBLE_EQ(opentelemetry::nostd::get(lastvalue_data.value_), + bg_noise_level_2_roomA); + } + count_attributes++; + } + else if (opentelemetry::nostd::get( + data_attr.attributes.find("Room.id")->second) == "Rack B") + { + if (temporality == AggregationTemporality::kCumulative) + { + EXPECT_DOUBLE_EQ(opentelemetry::nostd::get(lastvalue_data.value_), + bg_noise_level_2_roomB); + } + count_attributes++; + } + } + return true; + }); + EXPECT_EQ(count_attributes, 2); // RackA and RackB +#else + EXPECT_TRUE(true); +#endif +} + +INSTANTIATE_TEST_SUITE_P(WritableMetricStorageTestDouble, + WritableMetricStorageTestFixture, + ::testing::Values(AggregationTemporality::kCumulative)); diff --git a/deps/opentelemetry-cpp/sdk/test/resource/resource_test.cc b/deps/opentelemetry-cpp/sdk/test/resource/resource_test.cc index c15087e9b75..a359cb33d41 100644 --- a/deps/opentelemetry-cpp/sdk/test/resource/resource_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/resource/resource_test.cc @@ -14,8 +14,9 @@ #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/resource/resource_detector.h" -#include "opentelemetry/sdk/resource/semantic_conventions.h" #include "opentelemetry/sdk/version/version.h" +#include "opentelemetry/semconv/service_attributes.h" +#include "opentelemetry/semconv/telemetry_attributes.h" #if defined(_MSC_VER) # include "opentelemetry/sdk/common/env_variables.h" @@ -24,7 +25,8 @@ using opentelemetry::sdk::common::unsetenv; #endif using namespace opentelemetry::sdk::resource; -namespace nostd = opentelemetry::nostd; +namespace nostd = opentelemetry::nostd; +namespace semconv = opentelemetry::semconv; class TestResource : public Resource { @@ -41,10 +43,10 @@ TEST(ResourceTest, create_without_servicename) {"service", "backend"}, {"version", static_cast(1)}, {"cost", 234.23}, - {SemanticConventions::kTelemetrySdkLanguage, "cpp"}, - {SemanticConventions::kTelemetrySdkName, "opentelemetry"}, - {SemanticConventions::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, - {SemanticConventions::kServiceName, "unknown_service"}}; + {semconv::telemetry::kTelemetrySdkLanguage, "cpp"}, + {semconv::telemetry::kTelemetrySdkName, "opentelemetry"}, + {semconv::telemetry::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, + {semconv::service::kServiceName, "unknown_service"}}; ResourceAttributes attributes = { {"service", "backend"}, {"version", static_cast(1)}, {"cost", 234.23}}; @@ -74,10 +76,10 @@ TEST(ResourceTest, create_with_servicename) ResourceAttributes expected_attributes = { {"version", static_cast(1)}, {"cost", 234.23}, - {SemanticConventions::kTelemetrySdkLanguage, "cpp"}, - {SemanticConventions::kTelemetrySdkName, "opentelemetry"}, - {SemanticConventions::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, - {SemanticConventions::kServiceName, "backend"}, + {semconv::telemetry::kTelemetrySdkLanguage, "cpp"}, + {semconv::telemetry::kTelemetrySdkName, "opentelemetry"}, + {semconv::telemetry::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, + {semconv::service::kServiceName, "backend"}, }; ResourceAttributes attributes = { {"service.name", "backend"}, {"version", static_cast(1)}, {"cost", 234.23}}; @@ -105,10 +107,10 @@ TEST(ResourceTest, create_with_servicename) TEST(ResourceTest, create_with_emptyatrributes) { ResourceAttributes expected_attributes = { - {SemanticConventions::kTelemetrySdkLanguage, "cpp"}, - {SemanticConventions::kTelemetrySdkName, "opentelemetry"}, - {SemanticConventions::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, - {SemanticConventions::kServiceName, "unknown_service"}, + {semconv::telemetry::kTelemetrySdkLanguage, "cpp"}, + {semconv::telemetry::kTelemetrySdkName, "opentelemetry"}, + {semconv::telemetry::kTelemetrySdkVersion, OPENTELEMETRY_SDK_VERSION}, + {semconv::service::kServiceName, "unknown_service"}, }; ResourceAttributes attributes = {}; auto resource = Resource::Create(attributes); diff --git a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.proto b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1development/profiles_service.proto similarity index 91% rename from deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.proto rename to deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1development/profiles_service.proto index d0e7894b29c..ab2433ed29d 100644 --- a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.proto +++ b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1development/profiles_service.proto @@ -14,15 +14,15 @@ syntax = "proto3"; -package opentelemetry.proto.collector.profiles.v1experimental; +package opentelemetry.proto.collector.profiles.v1development; -import "opentelemetry/proto/profiles/v1experimental/profiles.proto"; +import "opentelemetry/proto/profiles/v1development/profiles.proto"; -option csharp_namespace = "OpenTelemetry.Proto.Collector.Profiles.V1Experimental"; +option csharp_namespace = "OpenTelemetry.Proto.Collector.Profiles.V1Development"; option java_multiple_files = true; -option java_package = "io.opentelemetry.proto.collector.profiles.v1experimental"; +option java_package = "io.opentelemetry.proto.collector.profiles.v1development"; option java_outer_classname = "ProfilesServiceProto"; -option go_package = "go.opentelemetry.io/proto/otlp/collector/profiles/v1experimental"; +option go_package = "go.opentelemetry.io/proto/otlp/collector/profiles/v1development"; // Service that can be used to push profiles between one Application instrumented with // OpenTelemetry and a collector, or between a collector and a central collector. @@ -38,7 +38,7 @@ message ExportProfilesServiceRequest { // element. Intermediary nodes (such as OpenTelemetry Collector) that receive // data from multiple origins typically batch the data before forwarding further and // in that case this array will contain multiple elements. - repeated opentelemetry.proto.profiles.v1experimental.ResourceProfiles resource_profiles = 1; + repeated opentelemetry.proto.profiles.v1development.ResourceProfiles resource_profiles = 1; } message ExportProfilesServiceResponse { diff --git a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1experimental/profiles_service_http.yaml b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1development/profiles_service_http.yaml similarity index 63% rename from deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1experimental/profiles_service_http.yaml rename to deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1development/profiles_service_http.yaml index ea501afbbb2..6b3b91da07e 100644 --- a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1experimental/profiles_service_http.yaml +++ b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/collector/profiles/v1development/profiles_service_http.yaml @@ -4,6 +4,6 @@ type: google.api.Service config_version: 3 http: rules: - - selector: opentelemetry.proto.collector.profiles.v1experimental.ProfilesService.Export - post: /v1experimental/profiles + - selector: opentelemetry.proto.collector.profiles.v1development.ProfilesService.Export + post: /v1development/profiles body: "*" diff --git a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto index 19bb7ff8d53..45e656735ad 100644 --- a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto +++ b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto @@ -29,6 +29,24 @@ option go_package = "go.opentelemetry.io/proto/otlp/metrics/v1"; // storage, OR can be embedded by other protocols that transfer OTLP metrics // data but do not implement the OTLP protocol. // +// MetricsData +// └─── ResourceMetrics +// ├── Resource +// ├── SchemaURL +// └── ScopeMetrics +// ├── Scope +// ├── SchemaURL +// └── Metric +// ├── Name +// ├── Description +// ├── Unit +// └── data +// ├── Gauge +// ├── Sum +// ├── Histogram +// ├── ExponentialHistogram +// └── Summary +// // The main difference between this message and collector protocol is that // in this message there will not be any "control" or "metadata" specific to // OTLP protocol. @@ -85,7 +103,6 @@ message ScopeMetrics { // // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md // -// // The data model and relation between entities is shown in the // diagram below. Here, "DataPoint" is the term used to refer to any // one of the specific data point value types, and "points" is the term used @@ -97,7 +114,7 @@ message ScopeMetrics { // - DataPoint contains timestamps, attributes, and one of the possible value type // fields. // -// Metric +// Metric // +------------+ // |name | // |description | @@ -251,6 +268,9 @@ message ExponentialHistogram { // data type. These data points cannot always be merged in a meaningful way. // While they can be useful in some applications, histogram data points are // recommended for new applications. +// Summary metrics do not have an aggregation temporality field. This is +// because the count and sum fields of a SummaryDataPoint are assumed to be +// cumulative values. message Summary { repeated SummaryDataPoint data_points = 1; } @@ -589,7 +609,8 @@ message ExponentialHistogramDataPoint { } // SummaryDataPoint is a single data point in a timeseries that describes the -// time-varying values of a Summary metric. +// time-varying values of a Summary metric. The count and sum fields represent +// cumulative values. message SummaryDataPoint { reserved 1; diff --git a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/pprofextended.proto b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1development/profiles.proto similarity index 56% rename from deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/pprofextended.proto rename to deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1development/profiles.proto index b5b5b88fcef..f1b31b68140 100644 --- a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/pprofextended.proto +++ b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1development/profiles.proto @@ -28,6 +28,124 @@ // See the License for the specific language governing permissions and // limitations under the License. +syntax = "proto3"; + +package opentelemetry.proto.profiles.v1development; + +import "opentelemetry/proto/common/v1/common.proto"; +import "opentelemetry/proto/resource/v1/resource.proto"; + +option csharp_namespace = "OpenTelemetry.Proto.Profiles.V1Development"; +option java_multiple_files = true; +option java_package = "io.opentelemetry.proto.profiles.v1development"; +option java_outer_classname = "ProfilesProto"; +option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1development"; + +// Relationships Diagram +// +// ┌──────────────────┐ LEGEND +// │ ProfilesData │ +// └──────────────────┘ ─────▶ embedded +// │ +// │ 1-n ─────▷ referenced by index +// ▼ +// ┌──────────────────┐ +// │ ResourceProfiles │ +// └──────────────────┘ +// │ +// │ 1-n +// ▼ +// ┌──────────────────┐ +// │ ScopeProfiles │ +// └──────────────────┘ +// │ +// │ 1-1 +// ▼ +// ┌──────────────────┐ +// │ Profile │ +// └──────────────────┘ +// │ n-1 +// │ 1-n ┌───────────────────────────────────────┐ +// ▼ │ ▽ +// ┌──────────────────┐ 1-n ┌──────────────┐ ┌──────────┐ +// │ Sample │ ──────▷ │ KeyValue │ │ Link │ +// └──────────────────┘ └──────────────┘ └──────────┘ +// │ 1-n △ △ +// │ 1-n ┌─────────────────┘ │ 1-n +// ▽ │ │ +// ┌──────────────────┐ n-1 ┌──────────────┐ +// │ Location │ ──────▷ │ Mapping │ +// └──────────────────┘ └──────────────┘ +// │ +// │ 1-n +// ▼ +// ┌──────────────────┐ +// │ Line │ +// └──────────────────┘ +// │ +// │ 1-1 +// ▽ +// ┌──────────────────┐ +// │ Function │ +// └──────────────────┘ +// + +// ProfilesData represents the profiles data that can be stored in persistent storage, +// OR can be embedded by other protocols that transfer OTLP profiles data but do not +// implement the OTLP protocol. +// +// The main difference between this message and collector protocol is that +// in this message there will not be any "control" or "metadata" specific to +// OTLP protocol. +// +// When new fields are added into this message, the OTLP request MUST be updated +// as well. +message ProfilesData { + // An array of ResourceProfiles. + // For data coming from a single resource this array will typically contain + // one element. Intermediary nodes that receive data from multiple origins + // typically batch the data before forwarding further and in that case this + // array will contain multiple elements. + repeated ResourceProfiles resource_profiles = 1; +} + + +// A collection of ScopeProfiles from a Resource. +message ResourceProfiles { + reserved 1000; + + // The resource for the profiles in this message. + // If this field is not set then no resource info is known. + opentelemetry.proto.resource.v1.Resource resource = 1; + + // A list of ScopeProfiles that originate from a resource. + repeated ScopeProfiles scope_profiles = 2; + + // The Schema URL, if known. This is the identifier of the Schema that the resource data + // is recorded in. To learn more about Schema URL see + // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url + // This schema_url applies to the data in the "resource" field. It does not apply + // to the data in the "scope_profiles" field which have their own schema_url field. + string schema_url = 3; +} + +// A collection of Profiles produced by an InstrumentationScope. +message ScopeProfiles { + // The instrumentation scope information for the profiles in this message. + // Semantically when InstrumentationScope isn't set, it is equivalent with + // an empty instrumentation scope name (unknown). + opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + + // A list of Profiles that originate from an instrumentation scope. + repeated Profile profiles = 2; + + // The Schema URL, if known. This is the identifier of the Schema that the profile data + // is recorded in. To learn more about Schema URL see + // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url + // This schema_url applies to all profiles in the "profiles" field. + string schema_url = 3; +} + // Profile is a common stacktrace profile format. // // Measurements represented with this format should follow the @@ -52,20 +170,15 @@ // mappings. For every nonzero Location.mapping_id there must be a // unique Mapping with that index. -syntax = "proto3"; - -package opentelemetry.proto.profiles.v1experimental; - -import "opentelemetry/proto/common/v1/common.proto"; - -option csharp_namespace = "OpenTelemetry.Proto.Profiles.V1Experimental"; -option java_multiple_files = true; -option java_package = "io.opentelemetry.proto.profiles.v1experimental"; -option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1experimental"; - // Represents a complete profile, including sample types, samples, // mappings to binaries, locations, functions, string table, and additional metadata. +// It modifies and annotates pprof Profile with OpenTelemetry specific fields. +// +// Note that whilst fields in this message retain the name and field id from pprof in most cases +// for ease of understanding data migration, it is not intended that pprof:Profile and +// OpenTelemetry:Profile encoding be wire compatible. message Profile { + // A description of the samples associated with each Sample.value. // For a cpu profile this might be: // [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]] @@ -79,58 +192,91 @@ message Profile { repeated Sample sample = 2; // Mapping from address ranges to the image/binary/library mapped // into that address range. mapping[0] will be the main binary. - repeated Mapping mapping = 3; + // If multiple binaries contribute to the Profile and no main + // binary can be identified, mapping[0] has no special meaning. + repeated Mapping mapping_table = 3; // Locations referenced by samples via location_indices. - repeated Location location = 4; + repeated Location location_table = 4; // Array of locations referenced by samples. - repeated int64 location_indices = 15; + repeated int32 location_indices = 5; // Functions referenced by locations. - repeated Function function = 5; + repeated Function function_table = 6; // Lookup table for attributes. - repeated opentelemetry.proto.common.v1.KeyValue attribute_table = 16; + repeated opentelemetry.proto.common.v1.KeyValue attribute_table = 7; // Represents a mapping between Attribute Keys and Units. - repeated AttributeUnit attribute_units = 17; + repeated AttributeUnit attribute_units = 8; // Lookup table for links. - repeated Link link_table = 18; + repeated Link link_table = 9; // A common table for strings referenced by various messages. // string_table[0] must always be "". - repeated string string_table = 6; - // frames with Function.function_name fully matching the following - // regexp will be dropped from the samples, along with their successors. - int64 drop_frames = 7; // Index into string table. - // frames with Function.function_name fully matching the following - // regexp will be kept, even if it matches drop_frames. - int64 keep_frames = 8; // Index into string table. - - // The following fields are informational, do not affect + repeated string string_table = 10; + + // The following fields 9-14 are informational, do not affect // interpretation of results. // Time of collection (UTC) represented as nanoseconds past the epoch. - int64 time_nanos = 9; + int64 time_nanos = 11; // Duration of the profile, if a duration makes sense. - int64 duration_nanos = 10; + int64 duration_nanos = 12; // The kind of events between sampled occurrences. // e.g [ "cpu","cycles" ] or [ "heap","bytes" ] - ValueType period_type = 11; + ValueType period_type = 13; // The number of events between sampled occurrences. - int64 period = 12; + int64 period = 14; // Free-form text associated with the profile. The text is displayed as is // to the user by the tools that read profiles (e.g. by pprof). This field // should not be used to store any machine-readable information, it is only // for human-friendly content. The profile must stay functional if this field // is cleaned. - repeated int64 comment = 13; // Indices into string table. + repeated int32 comment_strindices = 15; // Indices into string table. // Index into the string table of the type of the preferred sample // value. If unset, clients should default to the last sample value. - int64 default_sample_type = 14; + int32 default_sample_type_strindex = 16; + + + // A globally unique identifier for a profile. The ID is a 16-byte array. An ID with + // all zeroes is considered invalid. + // + // This field is required. + bytes profile_id = 17; + + // attributes is a collection of key/value pairs. Note, global attributes + // like server name can be set using the resource API. Examples of attributes: + // + // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" + // "/http/server_latency": 300 + // "abc.com/myattribute": true + // "abc.com/score": 10.239 + // + // The OpenTelemetry API specification further restricts the allowed value types: + // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute + // Attribute keys MUST be unique (it is not allowed to have more than one + // attribute with the same key). + repeated opentelemetry.proto.common.v1.KeyValue attributes = 18; + + // dropped_attributes_count is the number of attributes that were discarded. Attributes + // can be discarded because their keys are too long or because there are too many + // attributes. If this value is 0, then no attributes were dropped. + uint32 dropped_attributes_count = 19; + + // Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present] + string original_payload_format = 20; + + // Original payload can be stored in this field. This can be useful for users who want to get the original payload. + // Formats such as JFR are highly extensible and can contain more information than what is defined in this spec. + // Inclusion of original payload should be configurable by the user. Default behavior should be to not include the original payload. + // If the original payload is in pprof format, it SHOULD not be included in this field. + // The field is optional, however if it is present then equivalent converted data should be populated in other fields + // of this message as far as is practicable. + bytes original_payload = 21; } // Represents a mapping between Attribute Keys and Units. message AttributeUnit { // Index into string table. - int64 attribute_key = 1; + int32 attribute_key_strindex = 1; // Index into string table. - int64 unit = 2; + int32 unit_strindex = 2; } // A pointer from a profile Sample to a trace Span. @@ -214,8 +360,8 @@ enum AggregationTemporality { // ValueType describes the type and units of a value, with an optional aggregation temporality. message ValueType { - int64 type = 1; // Index into string table. - int64 unit = 2; // Index into string table. + int32 type_strindex = 1; // Index into string table. + int32 unit_strindex = 2; // Index into string table. AggregationTemporality aggregation_temporality = 3; } @@ -225,52 +371,36 @@ message ValueType { // augmented with auxiliary information like the thread-id, some // indicator of a higher level request being handled etc. message Sample { - // The indices recorded here correspond to locations in Profile.location. - // The leaf is at location_index[0]. [deprecated, superseded by locations_start_index / locations_length] - repeated uint64 location_index = 1; - // locations_start_index along with locations_length refers to to a slice of locations in Profile.location. + // locations_start_index along with locations_length refers to to a slice of locations in Profile.location_indices. + int32 locations_start_index = 1; + // locations_length along with locations_start_index refers to a slice of locations in Profile.location_indices. // Supersedes location_index. - uint64 locations_start_index = 7; - // locations_length along with locations_start_index refers to a slice of locations in Profile.location. - // Supersedes location_index. - uint64 locations_length = 8; - // A 128bit id that uniquely identifies this stacktrace, globally. Index into string table. [optional] - uint32 stacktrace_id_index = 9; + int32 locations_length = 2; // The type and unit of each value is defined by the corresponding // entry in Profile.sample_type. All samples must have the same // number of values, the same as the length of Profile.sample_type. // When aggregating multiple samples into a single sample, the // result has a list of values that is the element-wise sum of the // lists of the originals. - repeated int64 value = 2; - // label includes additional context for this sample. It can include - // things like a thread id, allocation size, etc. - // - // NOTE: While possible, having multiple values for the same label key is - // strongly discouraged and should never be used. Most tools (e.g. pprof) do - // not have good (or any) support for multi-value labels. And an even more - // discouraged case is having a string label and a numeric label of the same - // name on a sample. Again, possible to express, but should not be used. - // [deprecated, superseded by attributes] - repeated Label label = 3; + repeated int64 value = 3; // References to attributes in Profile.attribute_table. [optional] - repeated uint64 attributes = 10; + repeated int32 attribute_indices = 4; // Reference to link in Profile.link_table. [optional] - uint64 link = 12; + optional int32 link_index = 5; // Timestamps associated with Sample represented in nanoseconds. These timestamps are expected // to fall within the Profile's time range. [optional] - repeated uint64 timestamps_unix_nano = 13; + repeated uint64 timestamps_unix_nano = 6; } // Provides additional context for a sample, // such as thread ID or allocation size, with optional units. [deprecated] message Label { - int64 key = 1; // Index into string table + int32 key_strindex = 1; // Index into string table // At most one of the following must be present - int64 str = 2; // Index into string table + int32 str_strindex = 2; // Index into string table int64 num = 3; // Should only be present when num is present. @@ -280,65 +410,43 @@ message Label { // Consumers may also interpret units like "bytes" and "kilobytes" as memory // units and units like "seconds" and "nanoseconds" as time units, // and apply appropriate unit conversions to these. - int64 num_unit = 4; // Index into string table -} - -// Indicates the semantics of the build_id field. -enum BuildIdKind { - // Linker-generated build ID, stored in the ELF binary notes. - BUILD_ID_LINKER = 0; - // Build ID based on the content hash of the binary. Currently no particular - // hashing approach is standardized, so a given producer needs to define it - // themselves and thus unlike BUILD_ID_LINKER this kind of hash is producer-specific. - // We may choose to provide a standardized stable hash recommendation later. - BUILD_ID_BINARY_HASH = 1; + int32 num_unit_strindex = 4; // Index into string table } // Describes the mapping of a binary in memory, including its address range, // file offset, and metadata like build ID message Mapping { - // Unique nonzero id for the mapping. [deprecated] - uint64 id = 1; // Address at which the binary (or DLL) is loaded into memory. - uint64 memory_start = 2; + uint64 memory_start = 1; // The limit of the address range occupied by this mapping. - uint64 memory_limit = 3; + uint64 memory_limit = 2; // Offset in the binary that corresponds to the first mapped address. - uint64 file_offset = 4; + uint64 file_offset = 3; // The object this entry is loaded from. This can be a filename on // disk for the main binary and shared libraries, or virtual // abstractions like "[vdso]". - int64 filename = 5; // Index into string table - // A string that uniquely identifies a particular program version - // with high probability. E.g., for binaries generated by GNU tools, - // it could be the contents of the .note.gnu.build-id field. - int64 build_id = 6; // Index into string table - // Specifies the kind of build id. See BuildIdKind enum for more details [optional] - BuildIdKind build_id_kind = 11; + int32 filename_strindex = 4; // Index into string table // References to attributes in Profile.attribute_table. [optional] - repeated uint64 attributes = 12; + repeated int32 attribute_indices = 5; // The following fields indicate the resolution of symbolic info. - bool has_functions = 7; - bool has_filenames = 8; - bool has_line_numbers = 9; - bool has_inline_frames = 10; + bool has_functions = 6; + bool has_filenames = 7; + bool has_line_numbers = 8; + bool has_inline_frames = 9; } // Describes function and line table debug information. message Location { - // Unique nonzero id for the location. A profile could use - // instruction addresses or any integer sequence as ids. [deprecated] - uint64 id = 1; - // The index of the corresponding profile.Mapping for this location. + // Reference to mapping in Profile.mapping_table. // It can be unset if the mapping is unknown or not applicable for // this profile type. - uint64 mapping_index = 2; + optional int32 mapping_index = 1; // The instruction address for this location, if available. It // should be within [Mapping.memory_start...Mapping.memory_limit] // for the corresponding mapping. A non-leaf address may be in the // middle of a call instruction. It is up to display tools to find // the beginning of the instruction if necessary. - uint64 address = 3; + uint64 address = 2; // Multiple line indicates this location has inlined functions, // where the last entry represents the caller into which the // preceding entries were inlined. @@ -346,25 +454,22 @@ message Location { // E.g., if memcpy() is inlined into printf: // line[0].function_name == "memcpy" // line[1].function_name == "printf" - repeated Line line = 4; + repeated Line line = 3; // Provides an indication that multiple symbols map to this location's // address, for example due to identical code folding by the linker. In that // case the line information above represents one of the multiple // symbols. This field must be recomputed when the symbolization state of the // profile changes. - bool is_folded = 5; - - // Type of frame (e.g. kernel, native, python, hotspot, php). Index into string table. - uint32 type_index = 6; + bool is_folded = 4; // References to attributes in Profile.attribute_table. [optional] - repeated uint64 attributes = 7; + repeated int32 attribute_indices = 5; } // Details a specific line in a source code, linked to a function. message Line { - // The index of the corresponding profile.Function for this line. - uint64 function_index = 1; + // Reference to function in Profile.function_table. + int32 function_index = 1; // Line number in source code. int64 line = 2; // Column number in source code. @@ -374,15 +479,13 @@ message Line { // Describes a function, including its human-readable name, system name, // source file, and starting line number in the source. message Function { - // Unique nonzero id for the function. [deprecated] - uint64 id = 1; // Name of the function, in human-readable form if available. - int64 name = 2; // Index into string table + int32 name_strindex = 1; // Index into string table // Name of the function, as identified by the system. // For instance, it can be a C++ mangled name. - int64 system_name = 3; // Index into string table + int32 system_name_strindex = 2; // Index into string table // Source file containing the function. - int64 filename = 4; // Index into string table + int32 filename_strindex = 3; // Index into string table // Line number in source file. - int64 start_line = 5; + int64 start_line = 4; } diff --git a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/profiles.proto b/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/profiles.proto deleted file mode 100644 index 84b0108f86a..00000000000 --- a/deps/opentelemetry-cpp/third_party/opentelemetry-proto/opentelemetry/proto/profiles/v1experimental/profiles.proto +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright 2023, OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package opentelemetry.proto.profiles.v1experimental; - -import "opentelemetry/proto/common/v1/common.proto"; -import "opentelemetry/proto/resource/v1/resource.proto"; -import "opentelemetry/proto/profiles/v1experimental/pprofextended.proto"; - -option csharp_namespace = "OpenTelemetry.Proto.Profiles.V1Experimental"; -option java_multiple_files = true; -option java_package = "io.opentelemetry.proto.profiles.v1experimental"; -option java_outer_classname = "ProfilesProto"; -option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1experimental"; - -// Relationships Diagram -// -// ┌──────────────────┐ LEGEND -// │ ProfilesData │ -// └──────────────────┘ ─────▶ embedded -// │ -// │ 1-n ─────▷ referenced by index -// ▼ -// ┌──────────────────┐ -// │ ResourceProfiles │ -// └──────────────────┘ -// │ -// │ 1-n -// ▼ -// ┌──────────────────┐ -// │ ScopeProfiles │ -// └──────────────────┘ -// │ -// │ 1-n -// ▼ -// ┌──────────────────┐ -// │ ProfileContainer │ -// └──────────────────┘ -// │ -// │ 1-1 -// ▼ -// ┌──────────────────┐ -// │ Profile │ -// └──────────────────┘ -// │ n-1 -// │ 1-n ┌───────────────────────────────────────┐ -// ▼ │ ▽ -// ┌──────────────────┐ 1-n ┌──────────────┐ ┌──────────┐ -// │ Sample │ ──────▷ │ KeyValue │ │ Link │ -// └──────────────────┘ └──────────────┘ └──────────┘ -// │ 1-n △ △ -// │ 1-n ┌─────────────────┘ │ 1-n -// ▽ │ │ -// ┌──────────────────┐ n-1 ┌──────────────┐ -// │ Location │ ──────▷ │ Mapping │ -// └──────────────────┘ └──────────────┘ -// │ -// │ 1-n -// ▼ -// ┌──────────────────┐ -// │ Line │ -// └──────────────────┘ -// │ -// │ 1-1 -// ▽ -// ┌──────────────────┐ -// │ Function │ -// └──────────────────┘ -// - -// ProfilesData represents the profiles data that can be stored in persistent storage, -// OR can be embedded by other protocols that transfer OTLP profiles data but do not -// implement the OTLP protocol. -// -// The main difference between this message and collector protocol is that -// in this message there will not be any "control" or "metadata" specific to -// OTLP protocol. -// -// When new fields are added into this message, the OTLP request MUST be updated -// as well. -message ProfilesData { - // An array of ResourceProfiles. - // For data coming from a single resource this array will typically contain - // one element. Intermediary nodes that receive data from multiple origins - // typically batch the data before forwarding further and in that case this - // array will contain multiple elements. - repeated ResourceProfiles resource_profiles = 1; -} - - -// A collection of ScopeProfiles from a Resource. -message ResourceProfiles { - reserved 1000; - - // The resource for the profiles in this message. - // If this field is not set then no resource info is known. - opentelemetry.proto.resource.v1.Resource resource = 1; - - // A list of ScopeProfiles that originate from a resource. - repeated ScopeProfiles scope_profiles = 2; - - // The Schema URL, if known. This is the identifier of the Schema that the resource data - // is recorded in. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to the data in the "resource" field. It does not apply - // to the data in the "scope_profiles" field which have their own schema_url field. - string schema_url = 3; -} - -// A collection of ProfileContainers produced by an InstrumentationScope. -message ScopeProfiles { - // The instrumentation scope information for the profiles in this message. - // Semantically when InstrumentationScope isn't set, it is equivalent with - // an empty instrumentation scope name (unknown). - opentelemetry.proto.common.v1.InstrumentationScope scope = 1; - - // A list of ProfileContainers that originate from an instrumentation scope. - repeated ProfileContainer profiles = 2; - - // The Schema URL, if known. This is the identifier of the Schema that the metric data - // is recorded in. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to all profiles in the "profiles" field. - string schema_url = 3; -} - -// A ProfileContainer represents a single profile. It wraps pprof profile with OpenTelemetry specific metadata. -message ProfileContainer { - // A globally unique identifier for a profile. The ID is a 16-byte array. An ID with - // all zeroes is considered invalid. - // - // This field is required. - bytes profile_id = 1; - - // start_time_unix_nano is the start time of the profile. - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - // - // This field is semantically required and it is expected that end_time >= start_time. - fixed64 start_time_unix_nano = 2; - - // end_time_unix_nano is the end time of the profile. - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - // - // This field is semantically required and it is expected that end_time >= start_time. - fixed64 end_time_unix_nano = 3; - - // attributes is a collection of key/value pairs. Note, global attributes - // like server name can be set using the resource API. Examples of attributes: - // - // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" - // "/http/server_latency": 300 - // "abc.com/myattribute": true - // "abc.com/score": 10.239 - // - // The OpenTelemetry API specification further restricts the allowed value types: - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - repeated opentelemetry.proto.common.v1.KeyValue attributes = 4; - - // dropped_attributes_count is the number of attributes that were discarded. Attributes - // can be discarded because their keys are too long or because there are too many - // attributes. If this value is 0, then no attributes were dropped. - uint32 dropped_attributes_count = 5; - - // Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present] - string original_payload_format = 6; - - // Original payload can be stored in this field. This can be useful for users who want to get the original payload. - // Formats such as JFR are highly extensible and can contain more information than what is defined in this spec. - // Inclusion of original payload should be configurable by the user. Default behavior should be to not include the original payload. - // If the original payload is in pprof format, it SHOULD not be included in this field. - // The field is optional, however if it is present `profile` MUST be present and contain the same profiling information. - bytes original_payload = 7; - - // This is a reference to a pprof profile. Required, even when original_payload is present. - opentelemetry.proto.profiles.v1experimental.Profile profile = 8; -} diff --git a/deps/opentelemetry-cpp/third_party_release b/deps/opentelemetry-cpp/third_party_release index 7362473f609..75646fa6c9b 100644 --- a/deps/opentelemetry-cpp/third_party_release +++ b/deps/opentelemetry-cpp/third_party_release @@ -19,7 +19,7 @@ benchmark=v1.8.3 googletest=1.14.0 ms-gsl=v3.1.0-67-g6f45293 nlohmann-json=v3.11.3 -opentelemetry-proto=v1.3.2 +opentelemetry-proto=v1.4.0 opentracing-cpp=v1.6.0 -prometheus-cpp=v1.2.4 +prometheus-cpp=v1.3.0 vcpkg=2024.02.14 From 95cf54097a052d3a8166d2e4bb65b3aab792c0e2 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Wed, 18 Dec 2024 19:52:11 +0100 Subject: [PATCH 12/19] agents: share channel between OTLP exporters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will allow less grpc threads/resources to be used. PR-URL: https://github.com/nodesource/nsolid/pull/242 Reviewed-By: Juan José Arboleda --- agents/grpc/src/grpc_agent.cc | 51 ++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index bcc083dc032..4a5659c9af8 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -9,9 +9,14 @@ #include "absl/log/initialize.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" #include "opentelemetry/trace/semantic_conventions.h" @@ -29,12 +34,17 @@ using opentelemetry::sdk::metrics::ScopeMetrics; using opentelemetry::sdk::resource::Resource; using opentelemetry::sdk::resource::ResourceAttributes; using opentelemetry::sdk::trace::Recordable; +using opentelemetry::v1::exporter::otlp::OtlpGrpcClient; +using opentelemetry::v1::exporter::otlp::OtlpGrpcClientFactory; using opentelemetry::v1::exporter::otlp::OtlpGrpcClientOptions; using opentelemetry::v1::exporter::otlp::OtlpGrpcExporter; +using opentelemetry::v1::exporter::otlp::OtlpGrpcExporterFactory; using opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions; using opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporter; +using opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterFactory; using opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterOptions; using opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporter; +using opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterFactory; using opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterOptions; using opentelemetry::v1::exporter::otlp::OtlpMetricUtils; using opentelemetry::v1::trace::SemanticConventions::kProcessOwner; @@ -1019,6 +1029,24 @@ int GrpcAgent::config(const json& config) { it->get() : console_id_ + ".grpc.nodesource.io:443"; Debug("GrpcAgent configured. Endpoint: %s. Insecure: %d\n", endpoint.c_str(), static_cast(insecure)); + + + OtlpGrpcClientOptions opts; + opts.endpoint = endpoint; + opts.metadata = {{"nsolid-agent-id", agent_id_}, + {"nsolid-saas", saas_}}; + if (!insecure) { + opts.use_ssl_credentials = true; + if (!custom_certs_.empty()) { + opts.ssl_credentials_cacert_as_string = custom_certs_; + } else { + opts.ssl_credentials_cacert_as_string = cacert_; + } + } + + std::shared_ptr client = OtlpGrpcClientFactory::Create(opts); + nsolid_service_stub_ = GrpcClient::MakeNSolidServiceStub(opts); + { OtlpGrpcExporterOptions options; options.endpoint = endpoint; @@ -1033,7 +1061,7 @@ int GrpcAgent::config(const json& config) { } } - trace_exporter_ = std::make_unique(options); + trace_exporter_ = std::make_unique(options, client); } { OtlpGrpcMetricExporterOptions options; @@ -1049,7 +1077,8 @@ int GrpcAgent::config(const json& config) { } } - metrics_exporter_ = std::make_unique(options); + metrics_exporter_ = + std::make_unique(options, client); } { OtlpGrpcLogRecordExporterOptions options; @@ -1065,24 +1094,10 @@ int GrpcAgent::config(const json& config) { } } - log_exporter_ = std::make_unique(options); + log_exporter_ = + std::make_unique(options, client); } - { - OtlpGrpcClientOptions options; - options.endpoint = endpoint; - options.metadata = {{"nsolid-agent-id", agent_id_}, - {"nsolid-saas", saas_}}; - if (!insecure) { - options.use_ssl_credentials = true; - if (!custom_certs_.empty()) { - options.ssl_credentials_cacert_as_string = custom_certs_; - } else { - options.ssl_credentials_cacert_as_string = cacert_; - } - } - nsolid_service_stub_ = GrpcClient::MakeNSolidServiceStub(options); - } reset_command_stream(); } } From 1fa4424d7455c5daa12e2b13f990bbc49b54361d Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Tue, 10 Dec 2024 12:17:02 +0100 Subject: [PATCH 13/19] test: unflake nsolid-env-metrics test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodesource/nsolid/pull/236 Reviewed-By: Juan José Arboleda --- test/addons/nsolid-env-metrics/nsolid-env-metrics.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/addons/nsolid-env-metrics/nsolid-env-metrics.js b/test/addons/nsolid-env-metrics/nsolid-env-metrics.js index 2f8b0e29469..4fcb5311cd2 100644 --- a/test/addons/nsolid-env-metrics/nsolid-env-metrics.js +++ b/test/addons/nsolid-env-metrics/nsolid-env-metrics.js @@ -25,6 +25,7 @@ process.on('beforeExit', mustCall(() => { assert.strictEqual(binding.getCbCntr(), 11); })); +const workers = []; for (let i = 0; i < 10; i++) { const worker = new Worker(__filename, { argv: [process.pid] }); worker.on('exit', (code) => { @@ -33,12 +34,18 @@ for (let i = 0; i < 10; i++) { worker.on('message', mustCall((msg) => { assert.strictEqual(msg, 'init'); binding.getMetrics(worker.threadId); - worker.postMessage('exit'); })); + workers.push(worker); } // Let then main thread be a bit idle so we can check that loop_utilization is // correctly calculdate. setTimeout(() => { binding.getMetrics(); -}, 100); + const interval = setInterval(() => { + if (binding.getCbCntr() === 11) { + clearInterval(interval); + workers.forEach((worker) => worker.postMessage('exit')); + } + }, 50); +}, 300); From b46dd3981f79f974fb5fc214a12070bed2b3b1a6 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 12 Dec 2024 12:01:09 +0100 Subject: [PATCH 14/19] agents: improve SaaS token handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While also making sure we're able to connect correctly to both production and staging hosts. PR-URL: https://github.com/nodesource/nsolid/pull/237 Reviewed-By: Juan José Arboleda --- agents/grpc/src/grpc_agent.cc | 64 +++++++++++++++++++++-------------- agents/grpc/src/grpc_agent.h | 13 +++++-- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index 4a5659c9af8..d67dc5cdc61 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -66,6 +66,9 @@ const uint64_t auth_timer_interval = 500; const size_t GRPC_MAX_SIZE = 4L * 1024 * 1024; // 4GB +const int PUB_KEY_SIZE = 40; +const int CONSOLE_ID_SIZE = 36; + static const char* const root_certs[] = { #include "node_root_certs.h" // NOLINT(build/include_order) }; @@ -482,7 +485,7 @@ void GrpcAgent::reset_command_stream() { command_stream_ = std::make_unique(nsolid_service_stub_.get(), weak_from_this(), agent_id_, - saas_); + saas()); } void GrpcAgent::set_asset_cb(SharedEnvInst envinst, @@ -1002,11 +1005,9 @@ int GrpcAgent::config(const json& config) { if (utils::find_any_fields_in_diff(diff, { "/saas" })) { auto it = config_.find("saas"); + saas_.reset(); if (it != config_.end()) { parse_saas_token(*it); - } else { - saas_.clear(); - console_id_.clear(); } } @@ -1018,15 +1019,16 @@ int GrpcAgent::config(const json& config) { bool insecure = false; std::string insecure_str; // Only parse the insecure flag in non SaaS mode. - if (saas_.empty() && + if (!saas_ && per_process::system_environment-> Get(kNSOLID_GRPC_INSECURE).To(&insecure_str)) { // insecure = std::stoull(insecure_str); insecure = std::stoi(insecure_str); } - const std::string endpoint = console_id_.empty() ? - it->get() : console_id_ + ".grpc.nodesource.io:443"; + const std::string& endpoint = !saas_ ? + it->get() : + saas_->endpoint; Debug("GrpcAgent configured. Endpoint: %s. Insecure: %d\n", endpoint.c_str(), static_cast(insecure)); @@ -1034,7 +1036,7 @@ int GrpcAgent::config(const json& config) { OtlpGrpcClientOptions opts; opts.endpoint = endpoint; opts.metadata = {{"nsolid-agent-id", agent_id_}, - {"nsolid-saas", saas_}}; + {"nsolid-saas", saas()}}; if (!insecure) { opts.use_ssl_credentials = true; if (!custom_certs_.empty()) { @@ -1051,7 +1053,7 @@ int GrpcAgent::config(const json& config) { OtlpGrpcExporterOptions options; options.endpoint = endpoint; options.metadata = {{"nsolid-agent-id", agent_id_}, - {"nsolid-saas", saas_}}; + {"nsolid-saas", saas()}}; if (!insecure) { options.use_ssl_credentials = true; if (!custom_certs_.empty()) { @@ -1067,7 +1069,7 @@ int GrpcAgent::config(const json& config) { OtlpGrpcMetricExporterOptions options; options.endpoint = endpoint; options.metadata = {{"nsolid-agent-id", agent_id_}, - {"nsolid-saas", saas_}}; + {"nsolid-saas", saas()}}; if (!insecure) { options.use_ssl_credentials = true; if (!custom_certs_.empty()) { @@ -1084,7 +1086,7 @@ int GrpcAgent::config(const json& config) { OtlpGrpcLogRecordExporterOptions options; options.endpoint = endpoint; options.metadata = {{"nsolid-agent-id", agent_id_}, - {"nsolid-saas", saas_}}; + {"nsolid-saas", saas()}}; if (!insecure) { options.use_ssl_credentials = true; if (!custom_certs_.empty()) { @@ -1464,22 +1466,32 @@ void GrpcAgent::handle_command_request(CommandRequestStor&& req) { } void GrpcAgent::parse_saas_token(const std::string& token) { - std::string pubKey = token.substr(0, 40); + Debug("Parsing SaaS token: %s\n", token.c_str()); + std::string pubKey = token.substr(0, PUB_KEY_SIZE); std::replace(pubKey.begin(), pubKey.end(), ',', '!'); - std::string saasUrl = token.substr(40, token.length()); + std::string saasUrl = token.substr(PUB_KEY_SIZE, token.length()); std::string baseUrl; std::string basePort; std::istringstream saasStream(saasUrl); std::getline(saasStream, baseUrl, ':'); std::getline(saasStream, basePort, ':'); - if (baseUrl.empty() || basePort.empty() || pubKey.length() != 40) { + if (baseUrl.empty() || basePort.empty() || pubKey.length() != PUB_KEY_SIZE) { + Debug("Invalid SaaS token: %s\n", token.c_str()); + return; + } + + std::string console_id = baseUrl.substr(0, baseUrl.find('.')); + if (console_id.size() != CONSOLE_ID_SIZE) { Debug("Invalid SaaS token: %s\n", token.c_str()); return; } - saas_ = token; - console_id_ = baseUrl.substr(0, baseUrl.find('.')); + bool is_staging = token.find("staging") != std::string::npos; + std::string endpoint = is_staging ? + console_id + ".grpc.staging.nodesource.io:443" : + console_id + ".grpc.nodesource.io:443"; + saas_ = std::make_unique(SaaSInfo{token, std::move(endpoint)}); } bool GrpcAgent::pending_profiles() const { @@ -1571,7 +1583,7 @@ void GrpcAgent::send_blocked_loop_event(BlockedLoopStor&& stor) { Arena::Create(arena.get()); PopulateBlockedLoopEvent(event, stor); - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); GrpcClient::DelegateAsyncExport( nsolid_service_stub_.get(), std::move(context), std::move(arena), @@ -1607,7 +1619,7 @@ void GrpcAgent::send_exit() { exit_body->set_profile(cpu_profile_state.last_main_profile); } - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); uv_cond_t cond; uv_mutex_t lock; bool signaled = false; @@ -1656,7 +1668,7 @@ void GrpcAgent::send_info_event(const char* req_id) { PopulateInfoEvent(info_event, info, req_id); } - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); GrpcClient::DelegateAsyncExport( nsolid_service_stub_.get(), std::move(context), std::move(arena), @@ -1683,7 +1695,7 @@ void GrpcAgent::send_metrics_event(const char* req_id) { thr_metrics_cache_, req_id); - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); GrpcClient::DelegateAsyncExport( nsolid_service_stub_.get(), std::move(context), std::move(arena), @@ -1705,7 +1717,7 @@ void GrpcAgent::send_packages_event(const char* req_id) { auto packages_event = Arena::Create(arena.get()); PopulatePackagesEvent(packages_event, req_id); - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); GrpcClient::DelegateAsyncExport( nsolid_service_stub_.get(), std::move(context), std::move(arena), @@ -1728,7 +1740,7 @@ void GrpcAgent::send_reconfigure_event(const char* req_id) { Arena::Create(arena.get()); PopulateReconfigureEvent(reconfigure_event, req_id); - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); GrpcClient::DelegateAsyncExport( nsolid_service_stub_.get(), std::move(context), std::move(arena), @@ -1778,7 +1790,7 @@ void GrpcAgent::send_source_code_event(const grpcagent::CommandRequest& req) { } } - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); GrpcClient::DelegateAsyncExport( nsolid_service_stub_.get(), std::move(context), std::move(arena), @@ -1800,7 +1812,7 @@ void GrpcAgent::send_startup_times_event(const char* req_id) { auto st_event = Arena::Create(arena.get()); PopulateStartupTimesEvent(st_event, req_id); - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); GrpcClient::DelegateAsyncExport( nsolid_service_stub_.get(), std::move(context), std::move(arena), @@ -1824,7 +1836,7 @@ void GrpcAgent::send_unblocked_loop_event(BlockedLoopStor&& stor) { Arena::Create(arena.get()); PopulateUnblockedLoopEvent(event, stor); - auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + auto context = GrpcClient::MakeClientContext(agent_id_, saas()); GrpcClient::DelegateAsyncExport( nsolid_service_stub_.get(), std::move(context), std::move(arena), @@ -1926,7 +1938,7 @@ ErrorType GrpcAgent::do_start_prof_end(ErrorType err, AssetStor{type, thread_id}, weak_from_this(), agent_id_, - saas_); + saas()); if (err != ErrorType::ESuccess) { send_asset_error(type, req_id, std::move(opts), stream, err); return err; diff --git a/agents/grpc/src/grpc_agent.h b/agents/grpc/src/grpc_agent.h index 13192cca0f5..4fb6b33bfff 100644 --- a/agents/grpc/src/grpc_agent.h +++ b/agents/grpc/src/grpc_agent.h @@ -105,7 +105,10 @@ class GrpcAgent: public std::enable_shared_from_this, const std::string& agent_id() const { return agent_id_; } - const std::string& saas() const { return saas_; } + const std::string& saas() const { + static std::string empty; + return saas_ ? saas_->token : empty; + } private: struct CommandRequestStor { @@ -139,6 +142,11 @@ class GrpcAgent: public std::enable_shared_from_this, ProfileOptions options; }; + struct SaaSInfo { + std::string token; + std::string endpoint; + }; + GrpcAgent(); ~GrpcAgent(); @@ -325,8 +333,7 @@ class GrpcAgent: public std::enable_shared_from_this, TSQueue config_msg_q_; nlohmann::json config_; std::string agent_id_; - std::string saas_; - std::string console_id_; + std::unique_ptr saas_; nsuv::ns_timer auth_timer_; int auth_retries_; From 37c94afc3454600b427799d36c134de547424d8f Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Mon, 30 Dec 2024 11:25:09 +0100 Subject: [PATCH 15/19] deps: update libcurl to 8.11.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodesource/nsolid/pull/243 Reviewed-By: Juan José Arboleda --- deps/curl/include/Makefile.in | 1 + deps/curl/include/curl/Makefile.in | 1 + deps/curl/include/curl/curl.h | 10 +- deps/curl/include/curl/curlver.h | 8 +- deps/curl/lib/CMakeLists.txt | 2 +- deps/curl/lib/Makefile.in | 1 + deps/curl/lib/cf-h2-proxy.c | 4 +- deps/curl/lib/cf-socket.c | 47 ++++--- deps/curl/lib/config-win32.h | 4 - deps/curl/lib/cookie.c | 10 +- deps/curl/lib/curl_config.h.cmake | 3 - deps/curl/lib/curl_config.h.in | 5 +- deps/curl/lib/curl_ntlm_core.c | 26 +++- deps/curl/lib/curl_setup.h | 31 ++++- deps/curl/lib/curl_trc.c | 4 +- deps/curl/lib/easy.c | 1 + deps/curl/lib/formdata.c | 2 +- deps/curl/lib/hostip.c | 4 +- deps/curl/lib/http.c | 159 +-------------------- deps/curl/lib/http.h | 3 - deps/curl/lib/http2.c | 28 +++- deps/curl/lib/http2.h | 5 + deps/curl/lib/http_negotiate.c | 2 +- deps/curl/lib/http_proxy.c | 145 +++++++++++++++++++- deps/curl/lib/http_proxy.h | 6 + deps/curl/lib/krb5.c | 44 +++--- deps/curl/lib/ldap.c | 4 +- deps/curl/lib/md4.c | 7 + deps/curl/lib/md5.c | 27 +++- deps/curl/lib/mime.c | 62 +++++++-- deps/curl/lib/mprintf.c | 12 +- deps/curl/lib/multi.c | 11 ++ deps/curl/lib/netrc.c | 119 +++++++++------- deps/curl/lib/rtsp.c | 5 + deps/curl/lib/setopt.c | 6 +- deps/curl/lib/smb.c | 8 +- deps/curl/lib/socketpair.h | 16 +-- deps/curl/lib/strerror.c | 8 +- deps/curl/lib/strtok.h | 8 +- deps/curl/lib/url.c | 60 +++++--- deps/curl/lib/vauth/digest.c | 24 ++-- deps/curl/lib/version.c | 2 +- deps/curl/lib/vssh/libssh.c | 55 +++++++- deps/curl/lib/vssh/ssh.h | 4 + deps/curl/lib/vtls/mbedtls.c | 28 ++-- deps/curl/lib/vtls/openssl.c | 86 +++++------- deps/curl/lib/vtls/schannel.c | 198 +-------------------------- deps/curl/lib/vtls/schannel_verify.c | 3 +- deps/curl/lib/vtls/sectransp.c | 4 +- deps/curl/lib/vtls/wolfssl.c | 2 +- 50 files changed, 674 insertions(+), 641 deletions(-) diff --git a/deps/curl/include/Makefile.in b/deps/curl/include/Makefile.in index f02b8109cba..4d02e0439fd 100644 --- a/deps/curl/include/Makefile.in +++ b/deps/curl/include/Makefile.in @@ -295,6 +295,7 @@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBCURL_PC_CFLAGS = @LIBCURL_PC_CFLAGS@ LIBCURL_PC_CFLAGS_PRIVATE = @LIBCURL_PC_CFLAGS_PRIVATE@ +LIBCURL_PC_LDFLAGS_PRIVATE = @LIBCURL_PC_LDFLAGS_PRIVATE@ LIBCURL_PC_LIBS = @LIBCURL_PC_LIBS@ LIBCURL_PC_LIBS_PRIVATE = @LIBCURL_PC_LIBS_PRIVATE@ LIBCURL_PC_REQUIRES = @LIBCURL_PC_REQUIRES@ diff --git a/deps/curl/include/curl/Makefile.in b/deps/curl/include/curl/Makefile.in index ac2ddbf517e..6e85b3cdc9a 100644 --- a/deps/curl/include/curl/Makefile.in +++ b/deps/curl/include/curl/Makefile.in @@ -282,6 +282,7 @@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBCURL_PC_CFLAGS = @LIBCURL_PC_CFLAGS@ LIBCURL_PC_CFLAGS_PRIVATE = @LIBCURL_PC_CFLAGS_PRIVATE@ +LIBCURL_PC_LDFLAGS_PRIVATE = @LIBCURL_PC_LDFLAGS_PRIVATE@ LIBCURL_PC_LIBS = @LIBCURL_PC_LIBS@ LIBCURL_PC_LIBS_PRIVATE = @LIBCURL_PC_LIBS_PRIVATE@ LIBCURL_PC_REQUIRES = @LIBCURL_PC_REQUIRES@ diff --git a/deps/curl/include/curl/curl.h b/deps/curl/include/curl/curl.h index 21a552bc0ba..18835586a1e 100644 --- a/deps/curl/include/curl/curl.h +++ b/deps/curl/include/curl/curl.h @@ -551,14 +551,14 @@ typedef enum { CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ CURLE_OBSOLETE32, /* 32 - NOT USED */ CURLE_RANGE_ERROR, /* 33 - RANGE "command" did not work */ - CURLE_HTTP_POST_ERROR, /* 34 */ + CURLE_OBSOLETE34, /* 34 */ CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ CURLE_BAD_DOWNLOAD_RESUME, /* 36 - could not resume download */ CURLE_FILE_COULDNT_READ_FILE, /* 37 */ CURLE_LDAP_CANNOT_BIND, /* 38 */ CURLE_LDAP_SEARCH_FAILED, /* 39 */ CURLE_OBSOLETE40, /* 40 - NOT USED */ - CURLE_FUNCTION_NOT_FOUND, /* 41 - NOT USED starting with 7.53.0 */ + CURLE_OBSOLETE41, /* 41 - NOT USED starting with 7.53.0 */ CURLE_ABORTED_BY_CALLBACK, /* 42 */ CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ CURLE_OBSOLETE44, /* 44 - NOT USED */ @@ -643,6 +643,12 @@ typedef enum { #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all the obsolete stuff removed! */ +/* removed in 7.53.0 */ +#define CURLE_FUNCTION_NOT_FOUND CURLE_OBSOLETE41 + +/* removed in 7.56.0 */ +#define CURLE_HTTP_POST_ERROR CURLE_OBSOLETE34 + /* Previously obsolete error code reused in 7.38.0 */ #define CURLE_OBSOLETE16 CURLE_HTTP2 diff --git a/deps/curl/include/curl/curlver.h b/deps/curl/include/curl/curlver.h index bcfe3b089e3..3da578d15d9 100644 --- a/deps/curl/include/curl/curlver.h +++ b/deps/curl/include/curl/curlver.h @@ -32,13 +32,13 @@ /* This is the version number of the libcurl package from which this header file origins: */ -#define LIBCURL_VERSION "8.11.0" +#define LIBCURL_VERSION "8.11.1" /* The numeric version number is also available "in parts" by using these defines: */ #define LIBCURL_VERSION_MAJOR 8 #define LIBCURL_VERSION_MINOR 11 -#define LIBCURL_VERSION_PATCH 0 +#define LIBCURL_VERSION_PATCH 1 /* This is the numeric version of the libcurl version number, meant for easier parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will @@ -59,7 +59,7 @@ CURL_VERSION_BITS() macro since curl's own configure script greps for it and needs it to contain the full number. */ -#define LIBCURL_VERSION_NUM 0x080b00 +#define LIBCURL_VERSION_NUM 0x080b01 /* * This is the date and time when the full source package was created. The @@ -70,7 +70,7 @@ * * "2007-11-23" */ -#define LIBCURL_TIMESTAMP "2024-11-06" +#define LIBCURL_TIMESTAMP "2024-12-11" #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z)) #define CURL_AT_LEAST_VERSION(x,y,z) \ diff --git a/deps/curl/lib/CMakeLists.txt b/deps/curl/lib/CMakeLists.txt index 895bc9165ab..aea8616b25e 100644 --- a/deps/curl/lib/CMakeLists.txt +++ b/deps/curl/lib/CMakeLists.txt @@ -125,7 +125,7 @@ if(BUILD_STATIC_LIBS) add_library(${LIB_STATIC} STATIC ${LIB_SOURCE}) add_library(${PROJECT_NAME}::${LIB_STATIC} ALIAS ${LIB_STATIC}) if(WIN32) - set_property(TARGET ${LIB_OBJECT} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB") + set_property(TARGET ${LIB_STATIC} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB") endif() target_link_libraries(${LIB_STATIC} PRIVATE ${CURL_LIBS}) # Remove the "lib" prefix since the library is already named "libcurl". diff --git a/deps/curl/lib/Makefile.in b/deps/curl/lib/Makefile.in index 5c858b222cc..7f7847a77c4 100644 --- a/deps/curl/lib/Makefile.in +++ b/deps/curl/lib/Makefile.in @@ -1066,6 +1066,7 @@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBCURL_PC_CFLAGS = @LIBCURL_PC_CFLAGS@ LIBCURL_PC_CFLAGS_PRIVATE = @LIBCURL_PC_CFLAGS_PRIVATE@ +LIBCURL_PC_LDFLAGS_PRIVATE = @LIBCURL_PC_LDFLAGS_PRIVATE@ LIBCURL_PC_LIBS = @LIBCURL_PC_LIBS@ LIBCURL_PC_LIBS_PRIVATE = @LIBCURL_PC_LIBS_PRIVATE@ LIBCURL_PC_REQUIRES = @LIBCURL_PC_REQUIRES@ diff --git a/deps/curl/lib/cf-h2-proxy.c b/deps/curl/lib/cf-h2-proxy.c index 038952d6417..e687dd10507 100644 --- a/deps/curl/lib/cf-h2-proxy.c +++ b/deps/curl/lib/cf-h2-proxy.c @@ -277,6 +277,8 @@ static int proxy_h2_client_new(struct Curl_cfilter *cf, { struct cf_h2_proxy_ctx *ctx = cf->ctx; nghttp2_option *o; + nghttp2_mem mem = {NULL, Curl_nghttp2_malloc, Curl_nghttp2_free, + Curl_nghttp2_calloc, Curl_nghttp2_realloc}; int rc = nghttp2_option_new(&o); if(rc) @@ -289,7 +291,7 @@ static int proxy_h2_client_new(struct Curl_cfilter *cf, HTTP field value. */ nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation(o, 1); #endif - rc = nghttp2_session_client_new2(&ctx->h2, cbs, cf, o); + rc = nghttp2_session_client_new3(&ctx->h2, cbs, cf, o, &mem); nghttp2_option_del(o); return rc; } diff --git a/deps/curl/lib/cf-socket.c b/deps/curl/lib/cf-socket.c index b4840f7ebc5..497a3b965f1 100644 --- a/deps/curl/lib/cf-socket.c +++ b/deps/curl/lib/cf-socket.c @@ -600,36 +600,39 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn, if(!iface && !host && !port) /* no local kind of binding was requested */ return CURLE_OK; + else if(iface && (strlen(iface) >= 255) ) + return CURLE_BAD_FUNCTION_ARGUMENT; memset(&sa, 0, sizeof(struct Curl_sockaddr_storage)); - if(iface && (strlen(iface) < 255) ) { + if(iface || host) { char myhost[256] = ""; int done = 0; /* -1 for error, 1 for address found */ if2ip_result_t if2ip_result = IF2IP_NOT_FOUND; - /* interface */ #ifdef SO_BINDTODEVICE - /* - * This binds the local socket to a particular interface. This will - * force even requests to other local interfaces to go out the external - * interface. Only bind to the interface when specified as interface, - * not just as a hostname or ip address. - * - * The interface might be a VRF, eg: vrf-blue, which means it cannot be - * converted to an IP address and would fail Curl_if2ip. Simply try to - * use it straight away. - */ - if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, - iface, (curl_socklen_t)strlen(iface) + 1) == 0) { - /* This is often "errno 1, error: Operation not permitted" if you are - * not running as root or another suitable privileged user. If it - * succeeds it means the parameter was a valid interface and not an IP - * address. Return immediately. - */ - if(!host_input) { - infof(data, "socket successfully bound to interface '%s'", iface); - return CURLE_OK; + if(iface) { + /* + * This binds the local socket to a particular interface. This will + * force even requests to other local interfaces to go out the external + * interface. Only bind to the interface when specified as interface, + * not just as a hostname or ip address. + * + * The interface might be a VRF, eg: vrf-blue, which means it cannot be + * converted to an IP address and would fail Curl_if2ip. Simply try to + * use it straight away. + */ + if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, + iface, (curl_socklen_t)strlen(iface) + 1) == 0) { + /* This is often "errno 1, error: Operation not permitted" if you are + * not running as root or another suitable privileged user. If it + * succeeds it means the parameter was a valid interface and not an IP + * address. Return immediately. + */ + if(!host_input) { + infof(data, "socket successfully bound to interface '%s'", iface); + return CURLE_OK; + } } } #endif diff --git a/deps/curl/lib/config-win32.h b/deps/curl/lib/config-win32.h index e6abf062151..2daed912d0e 100644 --- a/deps/curl/lib/config-win32.h +++ b/deps/curl/lib/config-win32.h @@ -427,10 +427,6 @@ Vista # endif #endif -#ifdef USE_WIN32_LARGE_FILES -#define HAVE__FSEEKI64 -#endif - /* Define to the size of `off_t', as computed by sizeof. */ #if defined(__MINGW32__) && \ defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) diff --git a/deps/curl/lib/cookie.c b/deps/curl/lib/cookie.c index ca8c3c5967e..773e5357d3e 100644 --- a/deps/curl/lib/cookie.c +++ b/deps/curl/lib/cookie.c @@ -833,14 +833,16 @@ parse_netscape(struct Cookie *co, if(ptr) *ptr = 0; /* clear it */ - firstptr = strtok_r((char *)lineptr, "\t", &tok_buf); /* tokenize on TAB */ + /* tokenize on TAB */ + firstptr = Curl_strtok_r((char *)lineptr, "\t", &tok_buf); /* * Now loop through the fields and init the struct we already have * allocated */ fields = 0; - for(ptr = firstptr; ptr; ptr = strtok_r(NULL, "\t", &tok_buf), fields++) { + for(ptr = firstptr; ptr; + ptr = Curl_strtok_r(NULL, "\t", &tok_buf), fields++) { switch(fields) { case 0: if(ptr[0]=='.') /* skip preceding dots */ @@ -989,7 +991,7 @@ replace_existing(struct Curl_easy *data, size_t myhash = cookiehash(co->domain); for(n = Curl_llist_head(&ci->cookielist[myhash]); n; n = Curl_node_next(n)) { struct Cookie *clist = Curl_node_elem(n); - if(strcasecompare(clist->name, co->name)) { + if(!strcmp(clist->name, co->name)) { /* the names are identical */ bool matching_domains = FALSE; @@ -1029,7 +1031,7 @@ replace_existing(struct Curl_easy *data, } } - if(!replace_n && strcasecompare(clist->name, co->name)) { + if(!replace_n && !strcmp(clist->name, co->name)) { /* the names are identical */ if(clist->domain && co->domain) { diff --git a/deps/curl/lib/curl_config.h.cmake b/deps/curl/lib/curl_config.h.cmake index 7ee0a400f7f..1ac59ff057f 100644 --- a/deps/curl/lib/curl_config.h.cmake +++ b/deps/curl/lib/curl_config.h.cmake @@ -246,9 +246,6 @@ /* Define to 1 if you have the fseeko declaration. */ #cmakedefine HAVE_DECL_FSEEKO 1 -/* Define to 1 if you have the _fseeki64 function. */ -#cmakedefine HAVE__FSEEKI64 1 - /* Define to 1 if you have the ftruncate function. */ #cmakedefine HAVE_FTRUNCATE 1 diff --git a/deps/curl/lib/curl_config.h.in b/deps/curl/lib/curl_config.h.in index e0dd88e7809..15d6ee6118c 100644 --- a/deps/curl/lib/curl_config.h.in +++ b/deps/curl/lib/curl_config.h.in @@ -792,9 +792,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ZSTD_H -/* Define to 1 if you have the `_fseeki64' function. */ -#undef HAVE__FSEEKI64 - /* Define to 1 if you have the `_setmode' function. */ #undef HAVE__SETMODE @@ -881,7 +878,7 @@ /* GSASL support enabled */ #undef USE_GSASL -/* force HTTPS RR support for ECH */ +/* enable HTTPS RR support */ #undef USE_HTTPSRR /* if hyper is in use */ diff --git a/deps/curl/lib/curl_ntlm_core.c b/deps/curl/lib/curl_ntlm_core.c index 3cc885e03bd..54491fc0a89 100644 --- a/deps/curl/lib/curl_ntlm_core.c +++ b/deps/curl/lib/curl_ntlm_core.c @@ -71,13 +71,6 @@ # include # include # include -#else -# include -# include -# include -# include -#endif - # if (defined(OPENSSL_VERSION_NUMBER) && \ (OPENSSL_VERSION_NUMBER < 0x00907001L)) && !defined(USE_WOLFSSL) # define DES_key_schedule des_key_schedule @@ -95,6 +88,25 @@ # define DESKEYARG(x) *x # define DESKEY(x) &x # endif +#else +# include +# include +# include +# include +# if defined(OPENSSL_COEXIST) +# define DES_key_schedule WOLFSSL_DES_key_schedule +# define DES_cblock WOLFSSL_DES_cblock +# define DES_set_odd_parity wolfSSL_DES_set_odd_parity +# define DES_set_key wolfSSL_DES_set_key +# define DES_set_key_unchecked wolfSSL_DES_set_key_unchecked +# define DES_ecb_encrypt wolfSSL_DES_ecb_encrypt +# define DESKEY(x) ((WOLFSSL_DES_key_schedule *)(x)) +# define DESKEYARG(x) *x +# else +# define DESKEYARG(x) *x +# define DESKEY(x) &x +# endif +#endif #elif defined(USE_GNUTLS) diff --git a/deps/curl/lib/curl_setup.h b/deps/curl/lib/curl_setup.h index cfab1408504..50b4479f237 100644 --- a/deps/curl/lib/curl_setup.h +++ b/deps/curl/lib/curl_setup.h @@ -43,7 +43,7 @@ #include <_mingw.h> #endif -/* Workaround for Homebrew gcc 12.4.0, 13.3.0, 14.1.0 and newer (as of 14.1.0) +/* Workaround for Homebrew gcc 12.4.0, 13.3.0, 14.1.0, 14.2.0 (initial build) that started advertising the `availability` attribute, which then gets used by Apple SDK, but, in a way incompatible with gcc, resulting in misc errors inside SDK headers, e.g.: @@ -51,13 +51,16 @@ definition error: expected ',' or '}' before Followed by missing declarations. - Fix it by overriding the built-in feature-check macro used by the headers - to enable the problematic attributes. This makes the feature check fail. */ -#if defined(__APPLE__) && \ - !defined(__clang__) && \ - defined(__GNUC__) && __GNUC__ >= 12 && \ + Work it around by overriding the built-in feature-check macro used by the + headers to enable the problematic attributes. This makes the feature check + fail. Fixed in 14.2.0_1. Disable the workaround if the fix is detected. */ +#if defined(__APPLE__) && !defined(__clang__) && defined(__GNUC__) && \ defined(__has_attribute) -#define availability curl_pp_attribute_disabled +# if !defined(__has_feature) +# define availability curl_pp_attribute_disabled +# elif !__has_feature(attribute_availability) +# define availability curl_pp_attribute_disabled +# endif #endif #if defined(__APPLE__) @@ -287,6 +290,14 @@ # define CURL_DISABLE_HTTP_AUTH 1 #endif +/* + * ECH requires HTTPSRR. + */ + +#if defined(USE_ECH) && !defined(USE_HTTPSRR) +# define USE_HTTPSRR +#endif + /* ================================================================ */ /* No system header file shall be included in this file before this */ /* point. */ @@ -454,6 +465,12 @@ #include #endif +#ifdef _WIN32 +#define Curl_getpid() GetCurrentProcessId() +#else +#define Curl_getpid() getpid() +#endif + /* * Large file (>2Gb) support using Win32 functions. */ diff --git a/deps/curl/lib/curl_trc.c b/deps/curl/lib/curl_trc.c index 8f1be07e7d4..a3a107a4dc0 100644 --- a/deps/curl/lib/curl_trc.c +++ b/deps/curl/lib/curl_trc.c @@ -365,7 +365,7 @@ static CURLcode trc_opt(const char *config) if(!tmp) return CURLE_OUT_OF_MEMORY; - token = strtok_r(tmp, ", ", &tok_buf); + token = Curl_strtok_r(tmp, ", ", &tok_buf); while(token) { switch(*token) { case '-': @@ -391,7 +391,7 @@ static CURLcode trc_opt(const char *config) else trc_apply_level_by_name(token, lvl); - token = strtok_r(NULL, ", ", &tok_buf); + token = Curl_strtok_r(NULL, ", ", &tok_buf); } free(tmp); return CURLE_OK; diff --git a/deps/curl/lib/easy.c b/deps/curl/lib/easy.c index d16fa8c07af..ac8fab34220 100644 --- a/deps/curl/lib/easy.c +++ b/deps/curl/lib/easy.c @@ -940,6 +940,7 @@ CURL *curl_easy_duphandle(CURL *d) goto fail; Curl_dyn_init(&outcurl->state.headerb, CURL_MAX_HTTP_HEADER); + Curl_netrc_init(&outcurl->state.netrc); /* the connection pool is setup on demand */ outcurl->state.lastconnect_id = -1; diff --git a/deps/curl/lib/formdata.c b/deps/curl/lib/formdata.c index cea61b22e17..7ea7a8f396b 100644 --- a/deps/curl/lib/formdata.c +++ b/deps/curl/lib/formdata.c @@ -793,7 +793,7 @@ static CURLcode setname(curl_mimepart *part, const char *name, size_t len) /* wrap call to fseeko so it matches the calling convention of callback */ static int fseeko_wrapper(void *stream, curl_off_t offset, int whence) { -#if defined(HAVE__FSEEKI64) +#if defined(_WIN32) && defined(USE_WIN32_LARGE_FILES) return _fseeki64(stream, (__int64)offset, whence); #elif defined(HAVE_FSEEKO) && defined(HAVE_DECL_FSEEKO) return fseeko(stream, (off_t)offset, whence); diff --git a/deps/curl/lib/hostip.c b/deps/curl/lib/hostip.c index fe8cc5cb97f..1a9432d52af 100644 --- a/deps/curl/lib/hostip.c +++ b/deps/curl/lib/hostip.c @@ -798,7 +798,9 @@ enum resolve_t Curl_resolv(struct Curl_easy *data, return CURLRESOLV_ERROR; if(strcasecompare(hostname, "localhost") || - tailmatch(hostname, ".localhost")) + strcasecompare(hostname, "localhost.") || + tailmatch(hostname, ".localhost") || + tailmatch(hostname, ".localhost.")) addr = get_localhost(port, hostname); #ifndef CURL_DISABLE_DOH else if(allowDOH && data->set.doh && !ipnum) diff --git a/deps/curl/lib/http.c b/deps/curl/lib/http.c index a94edd61c23..35e70855152 100644 --- a/deps/curl/lib/http.c +++ b/deps/curl/lib/http.c @@ -1229,163 +1229,6 @@ static const char *get_http_string(const struct Curl_easy *data, } #endif -enum proxy_use { - HEADER_SERVER, /* direct to server */ - HEADER_PROXY, /* regular request to proxy */ - HEADER_CONNECT /* sending CONNECT to a proxy */ -}; - -static bool hd_name_eq(const char *n1, size_t n1len, - const char *n2, size_t n2len) -{ - if(n1len == n2len) { - return strncasecompare(n1, n2, n1len); - } - return FALSE; -} - -CURLcode Curl_dynhds_add_custom(struct Curl_easy *data, - bool is_connect, - struct dynhds *hds) -{ - struct connectdata *conn = data->conn; - char *ptr; - struct curl_slist *h[2]; - struct curl_slist *headers; - int numlists = 1; /* by default */ - int i; - -#ifndef CURL_DISABLE_PROXY - enum proxy_use proxy; - - if(is_connect) - proxy = HEADER_CONNECT; - else - proxy = conn->bits.httpproxy && !conn->bits.tunnel_proxy ? - HEADER_PROXY : HEADER_SERVER; - - switch(proxy) { - case HEADER_SERVER: - h[0] = data->set.headers; - break; - case HEADER_PROXY: - h[0] = data->set.headers; - if(data->set.sep_headers) { - h[1] = data->set.proxyheaders; - numlists++; - } - break; - case HEADER_CONNECT: - if(data->set.sep_headers) - h[0] = data->set.proxyheaders; - else - h[0] = data->set.headers; - break; - } -#else - (void)is_connect; - h[0] = data->set.headers; -#endif - - /* loop through one or two lists */ - for(i = 0; i < numlists; i++) { - for(headers = h[i]; headers; headers = headers->next) { - const char *name, *value; - size_t namelen, valuelen; - - /* There are 2 quirks in place for custom headers: - * 1. setting only 'name:' to suppress a header from being sent - * 2. setting only 'name;' to send an empty (illegal) header - */ - ptr = strchr(headers->data, ':'); - if(ptr) { - name = headers->data; - namelen = ptr - headers->data; - ptr++; /* pass the colon */ - while(*ptr && ISSPACE(*ptr)) - ptr++; - if(*ptr) { - value = ptr; - valuelen = strlen(value); - } - else { - /* quirk #1, suppress this header */ - continue; - } - } - else { - ptr = strchr(headers->data, ';'); - - if(!ptr) { - /* neither : nor ; in provided header value. We seem - * to ignore this silently */ - continue; - } - - name = headers->data; - namelen = ptr - headers->data; - ptr++; /* pass the semicolon */ - while(*ptr && ISSPACE(*ptr)) - ptr++; - if(!*ptr) { - /* quirk #2, send an empty header */ - value = ""; - valuelen = 0; - } - else { - /* this may be used for something else in the future, - * ignore this for now */ - continue; - } - } - - DEBUGASSERT(name && value); - if(data->state.aptr.host && - /* a Host: header was sent already, do not pass on any custom Host: - header as that will produce *two* in the same request! */ - hd_name_eq(name, namelen, STRCONST("Host:"))) - ; - else if(data->state.httpreq == HTTPREQ_POST_FORM && - /* this header (extended by formdata.c) is sent later */ - hd_name_eq(name, namelen, STRCONST("Content-Type:"))) - ; - else if(data->state.httpreq == HTTPREQ_POST_MIME && - /* this header is sent later */ - hd_name_eq(name, namelen, STRCONST("Content-Type:"))) - ; - else if(data->req.authneg && - /* while doing auth neg, do not allow the custom length since - we will force length zero then */ - hd_name_eq(name, namelen, STRCONST("Content-Length:"))) - ; - else if(data->state.aptr.te && - /* when asking for Transfer-Encoding, do not pass on a custom - Connection: */ - hd_name_eq(name, namelen, STRCONST("Connection:"))) - ; - else if((conn->httpversion >= 20) && - hd_name_eq(name, namelen, STRCONST("Transfer-Encoding:"))) - /* HTTP/2 does not support chunked requests */ - ; - else if((hd_name_eq(name, namelen, STRCONST("Authorization:")) || - hd_name_eq(name, namelen, STRCONST("Cookie:"))) && - /* be careful of sending this potentially sensitive header to - other hosts */ - !Curl_auth_allowed_to_host(data)) - ; - else { - CURLcode result; - - result = Curl_dynhds_add(hds, name, namelen, value, valuelen); - if(result) - return result; - } - } - } - - return CURLE_OK; -} - CURLcode Curl_add_custom_headers(struct Curl_easy *data, bool is_connect, #ifndef USE_HYPER @@ -1403,7 +1246,7 @@ CURLcode Curl_add_custom_headers(struct Curl_easy *data, int i; #ifndef CURL_DISABLE_PROXY - enum proxy_use proxy; + enum Curl_proxy_use proxy; if(is_connect) proxy = HEADER_CONNECT; diff --git a/deps/curl/lib/http.h b/deps/curl/lib/http.h index bb5974d94da..7056e8a8ed1 100644 --- a/deps/curl/lib/http.h +++ b/deps/curl/lib/http.h @@ -89,9 +89,6 @@ CURLcode Curl_add_custom_headers(struct Curl_easy *data, void *headers #endif ); -CURLcode Curl_dynhds_add_custom(struct Curl_easy *data, - bool is_connect, - struct dynhds *hds); void Curl_http_method(struct Curl_easy *data, struct connectdata *conn, const char **method, Curl_HttpReq *); diff --git a/deps/curl/lib/http2.c b/deps/curl/lib/http2.c index f1ee0cf9ec1..dbe6f1aaae6 100644 --- a/deps/curl/lib/http2.c +++ b/deps/curl/lib/http2.c @@ -433,6 +433,8 @@ static int h2_client_new(struct Curl_cfilter *cf, { struct cf_h2_ctx *ctx = cf->ctx; nghttp2_option *o; + nghttp2_mem mem = {NULL, Curl_nghttp2_malloc, Curl_nghttp2_free, + Curl_nghttp2_calloc, Curl_nghttp2_realloc}; int rc = nghttp2_option_new(&o); if(rc) @@ -445,7 +447,7 @@ static int h2_client_new(struct Curl_cfilter *cf, HTTP field value. */ nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation(o, 1); #endif - rc = nghttp2_session_client_new2(&ctx->h2, cbs, cf, o); + rc = nghttp2_session_client_new3(&ctx->h2, cbs, cf, o, &mem); nghttp2_option_del(o); return rc; } @@ -2960,6 +2962,30 @@ bool Curl_h2_http_1_1_error(struct Curl_easy *data) return FALSE; } +void *Curl_nghttp2_malloc(size_t size, void *user_data) +{ + (void)user_data; + return Curl_cmalloc(size); +} + +void Curl_nghttp2_free(void *ptr, void *user_data) +{ + (void)user_data; + Curl_cfree(ptr); +} + +void *Curl_nghttp2_calloc(size_t nmemb, size_t size, void *user_data) +{ + (void)user_data; + return Curl_ccalloc(nmemb, size); +} + +void *Curl_nghttp2_realloc(void *ptr, size_t size, void *user_data) +{ + (void)user_data; + return Curl_crealloc(ptr, size); +} + #else /* !USE_NGHTTP2 */ /* Satisfy external references even if http2 is not compiled in. */ diff --git a/deps/curl/lib/http2.h b/deps/curl/lib/http2.h index 80e183480a7..dbb1784661e 100644 --- a/deps/curl/lib/http2.h +++ b/deps/curl/lib/http2.h @@ -60,6 +60,11 @@ CURLcode Curl_http2_upgrade(struct Curl_easy *data, struct connectdata *conn, int sockindex, const char *ptr, size_t nread); +void *Curl_nghttp2_malloc(size_t size, void *user_data); +void Curl_nghttp2_free(void *ptr, void *user_data); +void *Curl_nghttp2_calloc(size_t nmemb, size_t size, void *user_data); +void *Curl_nghttp2_realloc(void *ptr, size_t size, void *user_data); + extern struct Curl_cftype Curl_cft_nghttp2; #else /* USE_NGHTTP2 */ diff --git a/deps/curl/lib/http_negotiate.c b/deps/curl/lib/http_negotiate.c index 5dda475057f..5d76bddf724 100644 --- a/deps/curl/lib/http_negotiate.c +++ b/deps/curl/lib/http_negotiate.c @@ -110,7 +110,7 @@ CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn, /* Check if the connection is using SSL and get the channel binding data */ #if defined(USE_SSL) && defined(HAVE_GSSAPI) if(conn->handler->flags & PROTOPT_SSL) { - Curl_dyn_init(&neg_ctx->channel_binding_data, SSL_CB_MAX_SIZE); + Curl_dyn_init(&neg_ctx->channel_binding_data, SSL_CB_MAX_SIZE + 1); result = Curl_ssl_get_channel_binding( data, FIRSTSOCKET, &neg_ctx->channel_binding_data); if(result) { diff --git a/deps/curl/lib/http_proxy.c b/deps/curl/lib/http_proxy.c index 1ec08d0d093..b1dbe984279 100644 --- a/deps/curl/lib/http_proxy.c +++ b/deps/curl/lib/http_proxy.c @@ -45,12 +45,155 @@ #include "vtls/vtls.h" #include "transfer.h" #include "multiif.h" +#include "vauth/vauth.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" #include "curl_memory.h" #include "memdebug.h" +static bool hd_name_eq(const char *n1, size_t n1len, + const char *n2, size_t n2len) +{ + return (n1len == n2len) ? strncasecompare(n1, n2, n1len) : FALSE; +} + +static CURLcode dynhds_add_custom(struct Curl_easy *data, + bool is_connect, + struct dynhds *hds) +{ + struct connectdata *conn = data->conn; + char *ptr; + struct curl_slist *h[2]; + struct curl_slist *headers; + int numlists = 1; /* by default */ + int i; + + enum Curl_proxy_use proxy; + + if(is_connect) + proxy = HEADER_CONNECT; + else + proxy = conn->bits.httpproxy && !conn->bits.tunnel_proxy ? + HEADER_PROXY : HEADER_SERVER; + + switch(proxy) { + case HEADER_SERVER: + h[0] = data->set.headers; + break; + case HEADER_PROXY: + h[0] = data->set.headers; + if(data->set.sep_headers) { + h[1] = data->set.proxyheaders; + numlists++; + } + break; + case HEADER_CONNECT: + if(data->set.sep_headers) + h[0] = data->set.proxyheaders; + else + h[0] = data->set.headers; + break; + } + + /* loop through one or two lists */ + for(i = 0; i < numlists; i++) { + for(headers = h[i]; headers; headers = headers->next) { + const char *name, *value; + size_t namelen, valuelen; + + /* There are 2 quirks in place for custom headers: + * 1. setting only 'name:' to suppress a header from being sent + * 2. setting only 'name;' to send an empty (illegal) header + */ + ptr = strchr(headers->data, ':'); + if(ptr) { + name = headers->data; + namelen = ptr - headers->data; + ptr++; /* pass the colon */ + while(*ptr && ISSPACE(*ptr)) + ptr++; + if(*ptr) { + value = ptr; + valuelen = strlen(value); + } + else { + /* quirk #1, suppress this header */ + continue; + } + } + else { + ptr = strchr(headers->data, ';'); + + if(!ptr) { + /* neither : nor ; in provided header value. We seem + * to ignore this silently */ + continue; + } + + name = headers->data; + namelen = ptr - headers->data; + ptr++; /* pass the semicolon */ + while(*ptr && ISSPACE(*ptr)) + ptr++; + if(!*ptr) { + /* quirk #2, send an empty header */ + value = ""; + valuelen = 0; + } + else { + /* this may be used for something else in the future, + * ignore this for now */ + continue; + } + } + + DEBUGASSERT(name && value); + if(data->state.aptr.host && + /* a Host: header was sent already, do not pass on any custom Host: + header as that will produce *two* in the same request! */ + hd_name_eq(name, namelen, STRCONST("Host:"))) + ; + else if(data->state.httpreq == HTTPREQ_POST_FORM && + /* this header (extended by formdata.c) is sent later */ + hd_name_eq(name, namelen, STRCONST("Content-Type:"))) + ; + else if(data->state.httpreq == HTTPREQ_POST_MIME && + /* this header is sent later */ + hd_name_eq(name, namelen, STRCONST("Content-Type:"))) + ; + else if(data->req.authneg && + /* while doing auth neg, do not allow the custom length since + we will force length zero then */ + hd_name_eq(name, namelen, STRCONST("Content-Length:"))) + ; + else if(data->state.aptr.te && + /* when asking for Transfer-Encoding, do not pass on a custom + Connection: */ + hd_name_eq(name, namelen, STRCONST("Connection:"))) + ; + else if((conn->httpversion >= 20) && + hd_name_eq(name, namelen, STRCONST("Transfer-Encoding:"))) + /* HTTP/2 does not support chunked requests */ + ; + else if((hd_name_eq(name, namelen, STRCONST("Authorization:")) || + hd_name_eq(name, namelen, STRCONST("Cookie:"))) && + /* be careful of sending this potentially sensitive header to + other hosts */ + !Curl_auth_allowed_to_host(data)) + ; + else { + CURLcode result; + + result = Curl_dynhds_add(hds, name, namelen, value, valuelen); + if(result) + return result; + } + } + } + + return CURLE_OK; +} CURLcode Curl_http_proxy_get_destination(struct Curl_cfilter *cf, const char **phostname, @@ -146,7 +289,7 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq, goto out; } - result = Curl_dynhds_add_custom(data, TRUE, &req->headers); + result = dynhds_add_custom(data, TRUE, &req->headers); out: if(result && req) { diff --git a/deps/curl/lib/http_proxy.h b/deps/curl/lib/http_proxy.h index 2b5f7ae7064..2e91ff20371 100644 --- a/deps/curl/lib/http_proxy.h +++ b/deps/curl/lib/http_proxy.h @@ -30,6 +30,12 @@ #include "urldata.h" +enum Curl_proxy_use { + HEADER_SERVER, /* direct to server */ + HEADER_PROXY, /* regular request to proxy */ + HEADER_CONNECT /* sending CONNECT to a proxy */ +}; + CURLcode Curl_http_proxy_get_destination(struct Curl_cfilter *cf, const char **phostname, int *pport, bool *pipv6_ip); diff --git a/deps/curl/lib/krb5.c b/deps/curl/lib/krb5.c index c953da6050a..e310a1b57a8 100644 --- a/deps/curl/lib/krb5.c +++ b/deps/curl/lib/krb5.c @@ -202,7 +202,8 @@ krb5_auth(void *app_data, struct Curl_easy *data, struct connectdata *conn) data->set.str[STRING_SERVICE_NAME] : "ftp"; const char *srv_host = "host"; - gss_buffer_desc input_buffer, output_buffer, _gssresp, *gssresp; + gss_buffer_desc input_buffer, output_buffer, *gssresp; + gss_buffer_desc _gssresp = GSS_C_EMPTY_BUFFER; OM_uint32 maj, min; gss_name_t gssname; gss_ctx_id_t *context = app_data; @@ -363,7 +364,7 @@ krb5_auth(void *app_data, struct Curl_easy *data, struct connectdata *conn) free(_gssresp.value); if(ret == AUTH_OK || service == srv_host) - return ret; + break; service = srv_host; } @@ -372,13 +373,13 @@ krb5_auth(void *app_data, struct Curl_easy *data, struct connectdata *conn) static void krb5_end(void *app_data) { - OM_uint32 min; - gss_ctx_id_t *context = app_data; - if(*context != GSS_C_NO_CONTEXT) { - OM_uint32 maj = gss_delete_sec_context(&min, context, GSS_C_NO_BUFFER); - (void)maj; - DEBUGASSERT(maj == GSS_S_COMPLETE); - } + OM_uint32 min; + gss_ctx_id_t *context = app_data; + if(*context != GSS_C_NO_CONTEXT) { + OM_uint32 maj = gss_delete_sec_context(&min, context, GSS_C_NO_BUFFER); + (void)maj; + DEBUGASSERT(maj == GSS_S_COMPLETE); + } } static const struct Curl_sec_client_mech Curl_krb5_client_mech = { @@ -612,10 +613,10 @@ static ssize_t sec_recv(struct Curl_easy *data, int sockindex, return total_read; } -/* Send |length| bytes from |from| to the |fd| socket taking care of encoding - and negotiating with the server. |from| can be NULL. */ +/* Send |length| bytes from |from| to the |sockindex| socket taking care of + encoding and negotiating with the server. |from| can be NULL. */ static void do_sec_send(struct Curl_easy *data, struct connectdata *conn, - curl_socket_t fd, const char *from, int length) + int sockindex, const char *from, int length) { int bytes, htonl_bytes; /* 32-bit integers for htonl */ char *buffer = NULL; @@ -649,12 +650,12 @@ static void do_sec_send(struct Curl_easy *data, struct connectdata *conn, static const char *enc = "ENC "; static const char *mic = "MIC "; if(prot_level == PROT_PRIVATE) - socket_write(data, fd, enc, 4); + socket_write(data, sockindex, enc, 4); else - socket_write(data, fd, mic, 4); + socket_write(data, sockindex, mic, 4); - socket_write(data, fd, cmd_buffer, cmd_size); - socket_write(data, fd, "\r\n", 2); + socket_write(data, sockindex, cmd_buffer, cmd_size); + socket_write(data, sockindex, "\r\n", 2); infof(data, "Send: %s%s", prot_level == PROT_PRIVATE ? enc : mic, cmd_buffer); free(cmd_buffer); @@ -662,14 +663,14 @@ static void do_sec_send(struct Curl_easy *data, struct connectdata *conn, } else { htonl_bytes = (int)htonl((OM_uint32)bytes); - socket_write(data, fd, &htonl_bytes, sizeof(htonl_bytes)); - socket_write(data, fd, buffer, curlx_sitouz(bytes)); + socket_write(data, sockindex, &htonl_bytes, sizeof(htonl_bytes)); + socket_write(data, sockindex, buffer, curlx_sitouz(bytes)); } free(buffer); } static ssize_t sec_write(struct Curl_easy *data, struct connectdata *conn, - curl_socket_t fd, const char *buffer, size_t length) + int sockindex, const char *buffer, size_t length) { ssize_t tx = 0, len = conn->buffer_size; @@ -679,7 +680,7 @@ static ssize_t sec_write(struct Curl_easy *data, struct connectdata *conn, if(length < (size_t)len) len = length; - do_sec_send(data, conn, fd, buffer, curlx_sztosi(len)); + do_sec_send(data, conn, sockindex, buffer, curlx_sztosi(len)); length -= len; buffer += len; tx += len; @@ -693,10 +694,9 @@ static ssize_t sec_send(struct Curl_easy *data, int sockindex, CURLcode *err) { struct connectdata *conn = data->conn; - curl_socket_t fd = conn->sock[sockindex]; (void)eos; /* unused */ *err = CURLE_OK; - return sec_write(data, conn, fd, buffer, len); + return sec_write(data, conn, sockindex, buffer, len); } int Curl_sec_read_msg(struct Curl_easy *data, struct connectdata *conn, diff --git a/deps/curl/lib/ldap.c b/deps/curl/lib/ldap.c index 01429ba79e8..2cbdb9c2142 100644 --- a/deps/curl/lib/ldap.c +++ b/deps/curl/lib/ldap.c @@ -825,8 +825,8 @@ static bool split_str(char *str, char ***out, size_t *count) if(!res) return FALSE; - for(i = 0, s = strtok_r(str, ",", &lasts); s && i < items; - s = strtok_r(NULL, ",", &lasts), i++) + for(i = 0, s = Curl_strtok_r(str, ",", &lasts); s && i < items; + s = Curl_strtok_r(NULL, ",", &lasts), i++) res[i] = s; *out = res; diff --git a/deps/curl/lib/md4.c b/deps/curl/lib/md4.c index f006bdcf052..8a3c8844154 100644 --- a/deps/curl/lib/md4.c +++ b/deps/curl/lib/md4.c @@ -115,6 +115,13 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx) #elif defined(USE_WOLFSSL) && !defined(WOLFSSL_NO_MD4) +#ifdef OPENSSL_COEXIST + #define MD4_CTX WOLFSSL_MD4_CTX + #define MD4_Init wolfSSL_MD4_Init + #define MD4_Update wolfSSL_MD4_Update + #define MD4_Final wolfSSL_MD4_Final +#endif + #elif defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD4) #elif defined(AN_APPLE_OS) diff --git a/deps/curl/lib/md5.c b/deps/curl/lib/md5.c index 73e04e37c10..1cf12318107 100644 --- a/deps/curl/lib/md5.c +++ b/deps/curl/lib/md5.c @@ -106,7 +106,8 @@ static void my_md5_final(unsigned char *digest, void *ctx) md5_digest(ctx, 16, digest); } -#elif defined(USE_OPENSSL_MD5) || defined(USE_WOLFSSL_MD5) +#elif defined(USE_OPENSSL_MD5) || \ + (defined(USE_WOLFSSL_MD5) && !defined(OPENSSL_COEXIST)) typedef MD5_CTX my_md5_ctx; @@ -130,6 +131,30 @@ static void my_md5_final(unsigned char *digest, void *ctx) (void)MD5_Final(digest, ctx); } +#elif defined(USE_WOLFSSL_MD5) + +typedef WOLFSSL_MD5_CTX my_md5_ctx; + +static CURLcode my_md5_init(void *ctx) +{ + if(!wolfSSL_MD5_Init(ctx)) + return CURLE_OUT_OF_MEMORY; + + return CURLE_OK; +} + +static void my_md5_update(void *ctx, + const unsigned char *input, + unsigned int len) +{ + (void)wolfSSL_MD5_Update(ctx, input, len); +} + +static void my_md5_final(unsigned char *digest, void *ctx) +{ + (void)wolfSSL_MD5_Final(digest, ctx); +} + #elif defined(USE_MBEDTLS) typedef mbedtls_md5_context my_md5_ctx; diff --git a/deps/curl/lib/mime.c b/deps/curl/lib/mime.c index 70286069ce0..21c40b06cb8 100644 --- a/deps/curl/lib/mime.c +++ b/deps/curl/lib/mime.c @@ -1926,6 +1926,7 @@ struct cr_mime_ctx { curl_off_t total_len; curl_off_t read_len; CURLcode error_result; + struct bufq tmpbuf; BIT(seen_eos); BIT(errored); }; @@ -1937,9 +1938,18 @@ static CURLcode cr_mime_init(struct Curl_easy *data, (void)data; ctx->total_len = -1; ctx->read_len = 0; + Curl_bufq_init2(&ctx->tmpbuf, 1024, 1, BUFQ_OPT_NO_SPARES); return CURLE_OK; } +static void cr_mime_close(struct Curl_easy *data, + struct Curl_creader *reader) +{ + struct cr_mime_ctx *ctx = reader->ctx; + (void)data; + Curl_bufq_free(&ctx->tmpbuf); +} + /* Real client reader to installed client callbacks. */ static CURLcode cr_mime_read(struct Curl_easy *data, struct Curl_creader *reader, @@ -1948,6 +1958,7 @@ static CURLcode cr_mime_read(struct Curl_easy *data, { struct cr_mime_ctx *ctx = reader->ctx; size_t nread; + char tmp[256]; /* Once we have errored, we will return the same error forever */ @@ -1973,18 +1984,46 @@ static CURLcode cr_mime_read(struct Curl_easy *data, blen = (size_t)remain; } - if(blen <= 4) { - /* TODO: Curl_mime_read() may go into an infinite loop when reading - * such small lengths. Returning 0 bytes read is a fix that only works - * as request upload buffers will get flushed eventually and larger - * reads will happen again. */ - CURL_TRC_READ(data, "cr_mime_read(len=%zu), too small, return", blen); - *pnread = 0; - *peos = FALSE; - goto out; + if(!Curl_bufq_is_empty(&ctx->tmpbuf)) { + CURLcode result = CURLE_OK; + ssize_t n = Curl_bufq_read(&ctx->tmpbuf, (unsigned char *)buf, blen, + &result); + if(n < 0) { + ctx->errored = TRUE; + ctx->error_result = result; + return result; + } + nread = (size_t)n; + } + else if(blen <= 4) { + /* Curl_mime_read() may go into an infinite loop when reading + * via a base64 encoder, as it stalls when the read buffer is too small + * to contain a complete 3 byte encoding. Read into a larger buffer + * and use that until empty. */ + CURL_TRC_READ(data, "cr_mime_read(len=%zu), small read, using tmp", blen); + nread = Curl_mime_read(tmp, 1, sizeof(tmp), ctx->part); + if(nread <= sizeof(tmp)) { + CURLcode result = CURLE_OK; + ssize_t n = Curl_bufq_write(&ctx->tmpbuf, (unsigned char *)tmp, nread, + &result); + if(n < 0) { + ctx->errored = TRUE; + ctx->error_result = result; + return result; + } + /* stored it, read again */ + n = Curl_bufq_read(&ctx->tmpbuf, (unsigned char *)buf, blen, &result); + if(n < 0) { + ctx->errored = TRUE; + ctx->error_result = result; + return result; + } + nread = (size_t)n; + } } + else + nread = Curl_mime_read(buf, 1, blen, ctx->part); - nread = Curl_mime_read(buf, 1, blen, ctx->part); CURL_TRC_READ(data, "cr_mime_read(len=%zu), mime_read() -> %zd", blen, nread); @@ -2044,7 +2083,6 @@ static CURLcode cr_mime_read(struct Curl_easy *data, break; } -out: CURL_TRC_READ(data, "cr_mime_read(len=%zu, total=%" FMT_OFF_T ", read=%"FMT_OFF_T") -> %d, %zu, %d", blen, ctx->total_len, ctx->read_len, CURLE_OK, *pnread, *peos); @@ -2140,7 +2178,7 @@ static const struct Curl_crtype cr_mime = { "cr-mime", cr_mime_init, cr_mime_read, - Curl_creader_def_close, + cr_mime_close, cr_mime_needs_rewind, cr_mime_total_length, cr_mime_resume_from, diff --git a/deps/curl/lib/mprintf.c b/deps/curl/lib/mprintf.c index 6576f3ebf9a..35e40e302de 100644 --- a/deps/curl/lib/mprintf.c +++ b/deps/curl/lib/mprintf.c @@ -321,10 +321,10 @@ static int parsefmt(const char *format, fmt++; } while(ISDIGIT(*fmt)) { - if(precision > INT_MAX/10) + int n = *fmt - '0'; + if(precision > (INT_MAX - n) / 10) return PFMT_PREC; - precision *= 10; - precision += *fmt - '0'; + precision = precision * 10 + n; fmt++; } if(is_neg) @@ -397,10 +397,10 @@ static int parsefmt(const char *format, width = 0; fmt--; do { - if(width > INT_MAX/10) + int n = *fmt - '0'; + if(width > (INT_MAX - n) / 10) return PFMT_WIDTH; - width *= 10; - width += *fmt - '0'; + width = width * 10 + n; fmt++; } while(ISDIGIT(*fmt)); break; diff --git a/deps/curl/lib/multi.c b/deps/curl/lib/multi.c index 263b396d3df..1851dc731e6 100644 --- a/deps/curl/lib/multi.c +++ b/deps/curl/lib/multi.c @@ -1541,6 +1541,9 @@ CURLMcode curl_multi_wakeup(CURLM *m) if(multi->wakeup_pair[1] != CURL_SOCKET_BAD) { #ifdef USE_EVENTFD buf = &val; + /* eventfd has a stringent rule of requiring the 8-byte buffer when + calling write(2) on it, which makes the sizeof(buf) below fine since + this is only used on 64-bit systems and then the pointer is 64-bit */ #else buf[0] = 1; #endif @@ -3586,6 +3589,14 @@ static CURLMcode multi_socket(struct Curl_multi *multi, } } } + else { + /* Asked to run due to time-out. Clear the 'last_expire_ts' variable to + force Curl_update_timer() to trigger a callback to the app again even + if the same timeout is still the one to run after this call. That + handles the case when the application asks libcurl to run the timeout + prematurely. */ + memset(&multi->last_expire_ts, 0, sizeof(multi->last_expire_ts)); + } result = multi_run_expired(&mrc); if(result) diff --git a/deps/curl/lib/netrc.c b/deps/curl/lib/netrc.c index c23f927cef3..d5ee3c0fd56 100644 --- a/deps/curl/lib/netrc.c +++ b/deps/curl/lib/netrc.c @@ -54,13 +54,16 @@ enum found_state { PASSWORD }; +#define FOUND_LOGIN 1 +#define FOUND_PASSWORD 2 + #define NETRC_FILE_MISSING 1 #define NETRC_FAILED -1 #define NETRC_SUCCESS 0 -#define MAX_NETRC_LINE 4096 -#define MAX_NETRC_FILE (64*1024) -#define MAX_NETRC_TOKEN 128 +#define MAX_NETRC_LINE 16384 +#define MAX_NETRC_FILE (128*1024) +#define MAX_NETRC_TOKEN 4096 static CURLcode file2memory(const char *filename, struct dynbuf *filebuf) { @@ -94,24 +97,24 @@ static CURLcode file2memory(const char *filename, struct dynbuf *filebuf) */ static int parsenetrc(struct store_netrc *store, const char *host, - char **loginp, + char **loginp, /* might point to a username */ char **passwordp, const char *netrcfile) { int retcode = NETRC_FILE_MISSING; char *login = *loginp; - char *password = *passwordp; - bool specific_login = (login && *login != 0); - bool login_alloc = FALSE; - bool password_alloc = FALSE; + char *password = NULL; + bool specific_login = !!login; /* points to something */ enum host_lookup_state state = NOTHING; - enum found_state found = NONE; - bool our_login = TRUE; /* With specific_login, found *our* login name (or - login-less line) */ + enum found_state keyword = NONE; + unsigned char found = 0; /* login + password found bits, as they can come in + any order */ + bool our_login = FALSE; /* found our login name */ bool done = FALSE; char *netrcbuffer; struct dynbuf token; struct dynbuf *filebuf = &store->filebuf; + DEBUGASSERT(!*passwordp); Curl_dyn_init(&token, MAX_NETRC_TOKEN); if(!store->loaded) { @@ -124,7 +127,7 @@ static int parsenetrc(struct store_netrc *store, while(!done) { char *tok = netrcbuffer; - while(tok) { + while(tok && !done) { char *tok_end; bool quoted; Curl_dyn_reset(&token); @@ -198,11 +201,6 @@ static int parsenetrc(struct store_netrc *store, } } - if((login && *login) && (password && *password)) { - done = TRUE; - break; - } - tok = Curl_dyn_ptr(&token); switch(state) { @@ -212,11 +210,18 @@ static int parsenetrc(struct store_netrc *store, contents begin with the next .netrc line and continue until a null line (consecutive new-line characters) is encountered. */ state = MACDEF; - else if(strcasecompare("machine", tok)) + else if(strcasecompare("machine", tok)) { /* the next tok is the machine name, this is in itself the delimiter that starts the stuff entered for this machine, after this we need to search for 'login' and 'password'. */ state = HOSTFOUND; + keyword = NONE; + found = 0; + our_login = FALSE; + Curl_safefree(password); + if(!specific_login) + Curl_safefree(login); + } else if(strcasecompare("default", tok)) { state = HOSTVALID; retcode = NETRC_SUCCESS; /* we did find our host */ @@ -238,44 +243,54 @@ static int parsenetrc(struct store_netrc *store, break; case HOSTVALID: /* we are now parsing sub-keywords concerning "our" host */ - if(found == LOGIN) { - if(specific_login) { + if(keyword == LOGIN) { + if(specific_login) our_login = !Curl_timestrcmp(login, tok); - } - else if(!login || Curl_timestrcmp(login, tok)) { - if(login_alloc) - free(login); + else { + our_login = TRUE; + free(login); login = strdup(tok); if(!login) { retcode = NETRC_FAILED; /* allocation failed */ goto out; } - login_alloc = TRUE; } - found = NONE; + found |= FOUND_LOGIN; + keyword = NONE; } - else if(found == PASSWORD) { - if((our_login || !specific_login) && - (!password || Curl_timestrcmp(password, tok))) { - if(password_alloc) - free(password); - password = strdup(tok); - if(!password) { - retcode = NETRC_FAILED; /* allocation failed */ - goto out; - } - password_alloc = TRUE; + else if(keyword == PASSWORD) { + free(password); + password = strdup(tok); + if(!password) { + retcode = NETRC_FAILED; /* allocation failed */ + goto out; } - found = NONE; + found |= FOUND_PASSWORD; + keyword = NONE; } else if(strcasecompare("login", tok)) - found = LOGIN; + keyword = LOGIN; else if(strcasecompare("password", tok)) - found = PASSWORD; + keyword = PASSWORD; else if(strcasecompare("machine", tok)) { - /* ok, there is machine here go => */ + /* a new machine here */ state = HOSTFOUND; - found = NONE; + keyword = NONE; + found = 0; + Curl_safefree(password); + if(!specific_login) + Curl_safefree(login); + } + else if(strcasecompare("default", tok)) { + state = HOSTVALID; + retcode = NETRC_SUCCESS; /* we did find our host */ + Curl_safefree(password); + if(!specific_login) + Curl_safefree(login); + } + if((found == (FOUND_PASSWORD|FOUND_LOGIN)) && our_login) { + done = TRUE; + break; } break; } /* switch (state) */ @@ -294,23 +309,23 @@ static int parsenetrc(struct store_netrc *store, out: Curl_dyn_free(&token); + if(!retcode && !password && our_login) { + /* success without a password, set a blank one */ + password = strdup(""); + if(!password) + retcode = 1; /* out of memory */ + } if(!retcode) { /* success */ - if(login_alloc) { - free(*loginp); + if(!specific_login) *loginp = login; - } - if(password_alloc) { - free(*passwordp); - *passwordp = password; - } + *passwordp = password; } else { Curl_dyn_free(filebuf); - if(login_alloc) + if(!specific_login) free(login); - if(password_alloc) - free(password); + free(password); } return retcode; diff --git a/deps/curl/lib/rtsp.c b/deps/curl/lib/rtsp.c index 0bd6ad6281e..ecefd132d2c 100644 --- a/deps/curl/lib/rtsp.c +++ b/deps/curl/lib/rtsp.c @@ -213,6 +213,11 @@ static CURLcode rtsp_done(struct Curl_easy *data, (data->conn->proto.rtspc.rtp_channel == -1)) { infof(data, "Got an RTP Receive with a CSeq of %ld", CSeq_recv); } + if(data->set.rtspreq == RTSPREQ_RECEIVE && + data->req.eos_written) { + failf(data, "Server prematurely closed the RTSP connection."); + return CURLE_RECV_ERROR; + } } return httpStatus; diff --git a/deps/curl/lib/setopt.c b/deps/curl/lib/setopt.c index 4f069721273..0bae6ba15b6 100644 --- a/deps/curl/lib/setopt.c +++ b/deps/curl/lib/setopt.c @@ -1146,7 +1146,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option, /* * raw data passed to the application when content encoding is used */ - data->set.http_ce_skip = enabled; + data->set.http_ce_skip = !enabled; /* reversed */ break; #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) @@ -1768,6 +1768,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, Curl_safefree(data->set.str[STRING_COPYPOSTFIELDS]); data->set.method = HTTPREQ_POST; break; +#endif /* ! CURL_DISABLE_HTTP || ! CURL_DISABLE_MQTT */ #ifndef CURL_DISABLE_HTTP case CURLOPT_ACCEPT_ENCODING: @@ -2186,7 +2187,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, * proxy exception list */ return Curl_setstropt(&data->set.str[STRING_NOPROXY], ptr); -#endif +#endif /* ! CURL_DISABLE_PROXY */ case CURLOPT_RANGE: /* @@ -2194,7 +2195,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, */ return Curl_setstropt(&data->set.str[STRING_SET_RANGE], ptr); -#endif /* ! CURL_DISABLE_PROXY */ case CURLOPT_CURLU: /* * pass CURLU to set URL diff --git a/deps/curl/lib/smb.c b/deps/curl/lib/smb.c index a242fc5c2a2..a72ece62ad7 100644 --- a/deps/curl/lib/smb.c +++ b/deps/curl/lib/smb.c @@ -27,12 +27,6 @@ #if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) -#ifdef _WIN32 -#define Curl_getpid() ((unsigned int)GetCurrentProcessId()) -#else -#define Curl_getpid() ((unsigned int)getpid()) -#endif - #include "smb.h" #include "urldata.h" #include "sendf.h" @@ -548,7 +542,7 @@ static void smb_format_message(struct Curl_easy *data, struct smb_header *h, h->flags2 = smb_swap16(SMB_FLAGS2_IS_LONG_NAME | SMB_FLAGS2_KNOWS_LONG_NAME); h->uid = smb_swap16(smbc->uid); h->tid = smb_swap16(req->tid); - pid = Curl_getpid(); + pid = (unsigned int)Curl_getpid(); h->pid_high = smb_swap16((unsigned short)(pid >> 16)); h->pid = smb_swap16((unsigned short) pid); } diff --git a/deps/curl/lib/socketpair.h b/deps/curl/lib/socketpair.h index 3044f1122ee..ed69c5af826 100644 --- a/deps/curl/lib/socketpair.h +++ b/deps/curl/lib/socketpair.h @@ -27,14 +27,14 @@ #include "curl_setup.h" #if defined(HAVE_EVENTFD) && \ - defined(__x86_64__) && \ - defined(__aarch64__) && \ - defined(__ia64__) && \ - defined(__ppc64__) && \ - defined(__mips64) && \ - defined(__sparc64__) && \ - defined(__riscv_64e) && \ - defined(__s390x__) + (defined(__x86_64__) || \ + defined(__aarch64__) || \ + defined(__ia64__) || \ + defined(__ppc64__) || \ + defined(__mips64) || \ + defined(__sparc64__) || \ + defined(__riscv_64e) || \ + defined(__s390x__)) /* Use eventfd only with 64-bit CPU architectures because eventfd has a * stringent rule of requiring the 8-byte buffer when calling read(2) and diff --git a/deps/curl/lib/strerror.c b/deps/curl/lib/strerror.c index 7d326e16f82..6b67a905880 100644 --- a/deps/curl/lib/strerror.c +++ b/deps/curl/lib/strerror.c @@ -151,9 +151,6 @@ curl_easy_strerror(CURLcode error) case CURLE_RANGE_ERROR: return "Requested range was not delivered by the server"; - case CURLE_HTTP_POST_ERROR: - return "Internal problem setting up the POST"; - case CURLE_SSL_CONNECT_ERROR: return "SSL connect error"; @@ -169,9 +166,6 @@ curl_easy_strerror(CURLcode error) case CURLE_LDAP_SEARCH_FAILED: return "LDAP: search failed"; - case CURLE_FUNCTION_NOT_FOUND: - return "A required function in the library was not found"; - case CURLE_ABORTED_BY_CALLBACK: return "Operation was aborted by an application callback"; @@ -330,7 +324,9 @@ curl_easy_strerror(CURLcode error) case CURLE_OBSOLETE24: case CURLE_OBSOLETE29: case CURLE_OBSOLETE32: + case CURLE_OBSOLETE34: case CURLE_OBSOLETE40: + case CURLE_OBSOLETE41: case CURLE_OBSOLETE44: case CURLE_OBSOLETE46: case CURLE_OBSOLETE50: diff --git a/deps/curl/lib/strtok.h b/deps/curl/lib/strtok.h index 321cba23262..9b4d06275fb 100644 --- a/deps/curl/lib/strtok.h +++ b/deps/curl/lib/strtok.h @@ -26,11 +26,11 @@ #include "curl_setup.h" #include -#ifndef HAVE_STRTOK_R -char *Curl_strtok_r(char *s, const char *delim, char **last); -#define strtok_r Curl_strtok_r -#else +#ifdef HAVE_STRTOK_R #include +#define Curl_strtok_r strtok_r +#else +char *Curl_strtok_r(char *s, const char *delim, char **last); #endif #endif /* HEADER_CURL_STRTOK_H */ diff --git a/deps/curl/lib/url.c b/deps/curl/lib/url.c index f9bb05f793e..436edd891e1 100644 --- a/deps/curl/lib/url.c +++ b/deps/curl/lib/url.c @@ -2651,6 +2651,17 @@ static CURLcode parse_remote_port(struct Curl_easy *data, return CURLE_OK; } +static bool str_has_ctrl(const char *input) +{ + const unsigned char *str = (const unsigned char *)input; + while(*str) { + if(*str < 0x20) + return TRUE; + str++; + } + return FALSE; +} + /* * Override the login details from the URL with that in the CURLOPT_USERPWD * option or a .netrc file, if applicable. @@ -2682,29 +2693,40 @@ static CURLcode override_login(struct Curl_easy *data, if(data->state.aptr.user && (data->state.creds_from != CREDS_NETRC)) { - /* there was a username in the URL. Use the URL decoded version */ + /* there was a username with a length in the URL. Use the URL decoded + version */ userp = &data->state.aptr.user; url_provided = TRUE; } - ret = Curl_parsenetrc(&data->state.netrc, conn->host.name, - userp, passwdp, - data->set.str[STRING_NETRC_FILE]); - if(ret > 0) { - infof(data, "Couldn't find host %s in the %s file; using defaults", - conn->host.name, - (data->set.str[STRING_NETRC_FILE] ? - data->set.str[STRING_NETRC_FILE] : ".netrc")); - } - else if(ret < 0) { - failf(data, ".netrc parser error"); - return CURLE_READ_ERROR; - } - else { - /* set bits.netrc TRUE to remember that we got the name from a .netrc - file, so that it is safe to use even if we followed a Location: to a - different host or similar. */ - conn->bits.netrc = TRUE; + if(!*passwdp) { + ret = Curl_parsenetrc(&data->state.netrc, conn->host.name, + userp, passwdp, + data->set.str[STRING_NETRC_FILE]); + if(ret > 0) { + infof(data, "Couldn't find host %s in the %s file; using defaults", + conn->host.name, + (data->set.str[STRING_NETRC_FILE] ? + data->set.str[STRING_NETRC_FILE] : ".netrc")); + } + else if(ret < 0) { + failf(data, ".netrc parser error"); + return CURLE_READ_ERROR; + } + else { + if(!(conn->handler->flags&PROTOPT_USERPWDCTRL)) { + /* if the protocol can't handle control codes in credentials, make + sure there are none */ + if(str_has_ctrl(*userp) || str_has_ctrl(*passwdp)) { + failf(data, "control code detected in .netrc credentials"); + return CURLE_READ_ERROR; + } + } + /* set bits.netrc TRUE to remember that we got the name from a .netrc + file, so that it is safe to use even if we followed a Location: to a + different host or similar. */ + conn->bits.netrc = TRUE; + } } if(url_provided) { Curl_safefree(conn->user); diff --git a/deps/curl/lib/vauth/digest.c b/deps/curl/lib/vauth/digest.c index cd3fca19ae1..0acfcace1d1 100644 --- a/deps/curl/lib/vauth/digest.c +++ b/deps/curl/lib/vauth/digest.c @@ -227,12 +227,12 @@ static CURLcode auth_digest_get_qop_values(const char *options, int *value) *value = 0; /* Tokenise the list of qop values. Use a temporary clone of the buffer since - strtok_r() ruins it. */ + Curl_strtok_r() ruins it. */ tmp = strdup(options); if(!tmp) return CURLE_OUT_OF_MEMORY; - token = strtok_r(tmp, ",", &tok_buf); + token = Curl_strtok_r(tmp, ",", &tok_buf); while(token) { if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH)) *value |= DIGEST_QOP_VALUE_AUTH; @@ -241,7 +241,7 @@ static CURLcode auth_digest_get_qop_values(const char *options, int *value) else if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH_CONF)) *value |= DIGEST_QOP_VALUE_AUTH_CONF; - token = strtok_r(NULL, ",", &tok_buf); + token = Curl_strtok_r(NULL, ",", &tok_buf); } free(tmp); @@ -553,12 +553,12 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg, else if(strcasecompare(value, "qop")) { char *tok_buf = NULL; /* Tokenize the list and choose auth if possible, use a temporary - clone of the buffer since strtok_r() ruins it */ + clone of the buffer since Curl_strtok_r() ruins it */ tmp = strdup(content); if(!tmp) return CURLE_OUT_OF_MEMORY; - token = strtok_r(tmp, ",", &tok_buf); + token = Curl_strtok_r(tmp, ",", &tok_buf); while(token) { /* Pass additional spaces here */ while(*token && ISBLANK(*token)) @@ -569,7 +569,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg, else if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH_INT)) { foundAuthInt = TRUE; } - token = strtok_r(NULL, ",", &tok_buf); + token = Curl_strtok_r(NULL, ",", &tok_buf); } free(tmp); @@ -709,13 +709,17 @@ static CURLcode auth_create_digest_http_message( digest->nc = 1; if(!digest->cnonce) { - char cnoncebuf[33]; - result = Curl_rand_hex(data, (unsigned char *)cnoncebuf, - sizeof(cnoncebuf)); + char cnoncebuf[12]; + result = Curl_rand_bytes(data, +#ifdef DEBUGBUILD + TRUE, +#endif + (unsigned char *)cnoncebuf, + sizeof(cnoncebuf)); if(result) return result; - result = Curl_base64_encode(cnoncebuf, strlen(cnoncebuf), + result = Curl_base64_encode(cnoncebuf, sizeof(cnoncebuf), &cnonce, &cnonce_sz); if(result) return result; diff --git a/deps/curl/lib/version.c b/deps/curl/lib/version.c index 1d5b96d2eb0..033349b511f 100644 --- a/deps/curl/lib/version.c +++ b/deps/curl/lib/version.c @@ -551,7 +551,7 @@ static const struct feat features_table[] = { #ifdef HAVE_ZSTD FEATURE("zstd", NULL, CURL_VERSION_ZSTD), #endif - {NULL, NULL, 0} + {NULL, NULL, 0} }; static const char *feature_names[sizeof(features_table) / diff --git a/deps/curl/lib/vssh/libssh.c b/deps/curl/lib/vssh/libssh.c index 2781365bf48..6bae061ac4e 100644 --- a/deps/curl/lib/vssh/libssh.c +++ b/deps/curl/lib/vssh/libssh.c @@ -1368,7 +1368,9 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) state machine to move on as soon as possible so we set a very short timeout here */ Curl_expire(data, 0, EXPIRE_RUN_NOW); - +#if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0) + sshc->sftp_send_state = 0; +#endif state(data, SSH_STOP); break; } @@ -1772,6 +1774,13 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) /* during times we get here due to a broken transfer and then the sftp_handle might not have been taken down so make sure that is done before we proceed */ + ssh_set_blocking(sshc->ssh_session, 0); +#if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0) + if(sshc->sftp_aio) { + sftp_aio_free(sshc->sftp_aio); + sshc->sftp_aio = NULL; + } +#endif if(sshc->sftp_file) { sftp_close(sshc->sftp_file); @@ -2191,7 +2200,14 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done) return CURLE_FAILED_INIT; } - rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name); + if(conn->bits.ipv6_ip) { + char ipv6[MAX_IPADR_LEN]; + msnprintf(ipv6, sizeof(ipv6), "[%s]", conn->host.name); + rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, ipv6); + } + else + rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name); + if(rc != SSH_OK) { failf(data, "Could not set remote host"); return CURLE_FAILED_INIT; @@ -2563,7 +2579,39 @@ static ssize_t sftp_send(struct Curl_easy *data, int sockindex, */ if(len > 32768) len = 32768; - +#if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0) + switch(conn->proto.sshc.sftp_send_state) { + case 0: + sftp_file_set_nonblocking(conn->proto.sshc.sftp_file); + if(sftp_aio_begin_write(conn->proto.sshc.sftp_file, mem, len, + &conn->proto.sshc.sftp_aio) == SSH_ERROR) { + *err = CURLE_SEND_ERROR; + return -1; + } + conn->proto.sshc.sftp_send_state = 1; + FALLTHROUGH(); + case 1: + nwrite = sftp_aio_wait_write(&conn->proto.sshc.sftp_aio); + myssh_block2waitfor(conn, (nwrite == SSH_AGAIN) ? TRUE : FALSE); + if(nwrite == SSH_AGAIN) { + *err = CURLE_AGAIN; + return 0; + } + else if(nwrite < 0) { + *err = CURLE_SEND_ERROR; + return -1; + } + if(conn->proto.sshc.sftp_aio) { + sftp_aio_free(conn->proto.sshc.sftp_aio); + conn->proto.sshc.sftp_aio = NULL; + } + conn->proto.sshc.sftp_send_state = 0; + return nwrite; + default: + /* we never reach here */ + return -1; + } +#else nwrite = sftp_write(conn->proto.sshc.sftp_file, mem, len); myssh_block2waitfor(conn, FALSE); @@ -2581,6 +2629,7 @@ static ssize_t sftp_send(struct Curl_easy *data, int sockindex, } return nwrite; +#endif } /* diff --git a/deps/curl/lib/vssh/ssh.h b/deps/curl/lib/vssh/ssh.h index f2d42a3de2a..8d8a9b38078 100644 --- a/deps/curl/lib/vssh/ssh.h +++ b/deps/curl/lib/vssh/ssh.h @@ -177,6 +177,10 @@ struct ssh_conn { sftp_dir sftp_dir; unsigned sftp_recv_state; /* 0 or 1 */ +#if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0) + sftp_aio sftp_aio; + unsigned sftp_send_state; /* 0 or 1 */ +#endif int sftp_file_index; /* for async read */ sftp_attributes readdir_attrs; /* used by the SFTP readdir actions */ sftp_attributes readdir_link_attrs; /* used by the SFTP readdir actions */ diff --git a/deps/curl/lib/vtls/mbedtls.c b/deps/curl/lib/vtls/mbedtls.c index 7a34e9c183b..e071ded72fc 100644 --- a/deps/curl/lib/vtls/mbedtls.c +++ b/deps/curl/lib/vtls/mbedtls.c @@ -54,7 +54,7 @@ # ifdef MBEDTLS_DEBUG # include # endif -#endif +#endif /* MBEDTLS_VERSION_MAJOR >= 2 */ #include "cipher_suite.h" #include "strcase.h" @@ -122,7 +122,7 @@ struct mbed_ssl_backend_data { #define HAS_SESSION_TICKETS #endif -#if defined(THREADING_SUPPORT) +#ifdef THREADING_SUPPORT static mbedtls_entropy_context ts_entropy; static int entropy_init_initialized = 0; @@ -585,16 +585,6 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) return CURLE_NOT_BUILT_IN; } -#ifdef TLS13_SUPPORT - ret = psa_crypto_init(); - if(ret != PSA_SUCCESS) { - mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "mbedTLS psa_crypto_init returned (-0x%04X) %s", - -ret, errorbuf); - return CURLE_SSL_CONNECT_ERROR; - } -#endif /* TLS13_SUPPORT */ - #ifdef THREADING_SUPPORT mbedtls_ctr_drbg_init(&backend->ctr_drbg); @@ -1571,6 +1561,20 @@ static int mbedtls_init(void) #ifdef THREADING_SUPPORT entropy_init_mutex(&ts_entropy); #endif +#ifdef TLS13_SUPPORT + { + int ret; +#ifdef THREADING_SUPPORT + Curl_mbedtlsthreadlock_lock_function(0); +#endif + ret = psa_crypto_init(); +#ifdef THREADING_SUPPORT + Curl_mbedtlsthreadlock_unlock_function(0); +#endif + if(ret != PSA_SUCCESS) + return 0; + } +#endif /* TLS13_SUPPORT */ return 1; } diff --git a/deps/curl/lib/vtls/openssl.c b/deps/curl/lib/vtls/openssl.c index e8be5d0ccd9..1b0e8dd5f0e 100644 --- a/deps/curl/lib/vtls/openssl.c +++ b/deps/curl/lib/vtls/openssl.c @@ -83,7 +83,7 @@ #include #ifdef USE_ECH -# ifndef OPENSSL_IS_BORINGSSL +# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) # include # endif # include "curl_base64.h" @@ -1152,9 +1152,8 @@ static bool is_pkcs11_uri(const char *string) static CURLcode ossl_set_engine(struct Curl_easy *data, const char *engine); -static int -SSL_CTX_use_certificate_blob(SSL_CTX *ctx, const struct curl_blob *blob, - int type, const char *key_passwd) +static int use_certificate_blob(SSL_CTX *ctx, const struct curl_blob *blob, + int type, const char *key_passwd) { int ret = 0; X509 *x = NULL; @@ -1190,9 +1189,8 @@ SSL_CTX_use_certificate_blob(SSL_CTX *ctx, const struct curl_blob *blob, return ret; } -static int -SSL_CTX_use_PrivateKey_blob(SSL_CTX *ctx, const struct curl_blob *blob, - int type, const char *key_passwd) +static int use_privatekey_blob(SSL_CTX *ctx, const struct curl_blob *blob, + int type, const char *key_passwd) { int ret = 0; EVP_PKEY *pkey = NULL; @@ -1205,14 +1203,12 @@ SSL_CTX_use_PrivateKey_blob(SSL_CTX *ctx, const struct curl_blob *blob, (void *)key_passwd); else if(type == SSL_FILETYPE_ASN1) pkey = d2i_PrivateKey_bio(in, NULL); - else { - ret = 0; + else goto end; - } - if(!pkey) { - ret = 0; + + if(!pkey) goto end; - } + ret = SSL_CTX_use_PrivateKey(ctx, pkey); EVP_PKEY_free(pkey); end: @@ -1221,8 +1217,8 @@ SSL_CTX_use_PrivateKey_blob(SSL_CTX *ctx, const struct curl_blob *blob, } static int -SSL_CTX_use_certificate_chain_blob(SSL_CTX *ctx, const struct curl_blob *blob, - const char *key_passwd) +use_certificate_chain_blob(SSL_CTX *ctx, const struct curl_blob *blob, + const char *key_passwd) { /* SSL_CTX_add1_chain_cert introduced in OpenSSL 1.0.2 */ #if (OPENSSL_VERSION_NUMBER >= 0x1000200fL) && /* OpenSSL 1.0.2 or later */ \ @@ -1239,11 +1235,8 @@ SSL_CTX_use_certificate_chain_blob(SSL_CTX *ctx, const struct curl_blob *blob, x = PEM_read_bio_X509_AUX(in, NULL, passwd_callback, (void *)key_passwd); - - if(!x) { - ret = 0; + if(!x) goto end; - } ret = SSL_CTX_use_certificate(ctx, x); @@ -1324,7 +1317,7 @@ int cert_stuff(struct Curl_easy *data, case SSL_FILETYPE_PEM: /* SSL_CTX_use_certificate_chain_file() only works on PEM files */ cert_use_result = cert_blob ? - SSL_CTX_use_certificate_chain_blob(ctx, cert_blob, key_passwd) : + use_certificate_chain_blob(ctx, cert_blob, key_passwd) : SSL_CTX_use_certificate_chain_file(ctx, cert_file); if(cert_use_result != 1) { failf(data, @@ -1344,8 +1337,7 @@ int cert_stuff(struct Curl_easy *data, ASN1 files. */ cert_use_result = cert_blob ? - SSL_CTX_use_certificate_blob(ctx, cert_blob, - file_type, key_passwd) : + use_certificate_blob(ctx, cert_blob, file_type, key_passwd) : SSL_CTX_use_certificate_file(ctx, cert_file, file_type); if(cert_use_result != 1) { failf(data, @@ -1554,7 +1546,7 @@ int cert_stuff(struct Curl_easy *data, FALLTHROUGH(); case SSL_FILETYPE_ASN1: cert_use_result = key_blob ? - SSL_CTX_use_PrivateKey_blob(ctx, key_blob, file_type, key_passwd) : + use_privatekey_blob(ctx, key_blob, file_type, key_passwd) : SSL_CTX_use_PrivateKey_file(ctx, key_file, file_type); if(cert_use_result != 1) { failf(data, "unable to set private key file: '%s' type %s", @@ -3674,14 +3666,14 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, SSL_CTX_set_mode(octx->ssl_ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); #endif -#ifdef HAS_ALPN if(alpn && alpn_len) { +#ifdef HAS_ALPN if(SSL_CTX_set_alpn_protos(octx->ssl_ctx, alpn, (int)alpn_len)) { failf(data, "Error setting ALPN"); return CURLE_SSL_CONNECT_ERROR; } - } #endif + } if(ssl_cert || ssl_cert_blob || ssl_cert_type) { if(!result && @@ -3849,15 +3841,15 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, if(data->set.tls_ech & CURLECH_GREASE) { infof(data, "ECH: will GREASE ClientHello"); -# ifdef OPENSSL_IS_BORINGSSL +# if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) SSL_set_enable_ech_grease(octx->ssl, 1); # else SSL_set_options(octx->ssl, SSL_OP_ECH_GREASE); # endif } else if(data->set.tls_ech & CURLECH_CLA_CFG) { -# ifdef OPENSSL_IS_BORINGSSL - /* have to do base64 decode here for boring */ +# if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) + /* have to do base64 decode here for BoringSSL */ const char *b64 = data->set.str[STRING_ECH_CONFIG]; if(!b64) { @@ -3917,7 +3909,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, size_t elen = rinfo->echconfiglist_len; infof(data, "ECH: ECHConfig from DoH HTTPS RR"); -# ifndef OPENSSL_IS_BORINGSSL +# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) if(SSL_ech_set1_echconfig(octx->ssl, ecl, elen) != 1) { infof(data, "ECH: SSL_ECH_set1_echconfig failed"); if(data->set.tls_ech & CURLECH_HARD) @@ -3925,7 +3917,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, } # else if(SSL_set1_ech_config_list(octx->ssl, ecl, elen) != 1) { - infof(data, "ECH: SSL_set1_ech_config_list failed (boring)"); + infof(data, "ECH: SSL_set1_ech_config_list failed (BoringSSL)"); if(data->set.tls_ech & CURLECH_HARD) return CURLE_SSL_CONNECT_ERROR; } @@ -3943,7 +3935,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, Curl_resolv_unlink(data, &dns); } } -# ifdef OPENSSL_IS_BORINGSSL +# if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) if(trying_ech_now && outername) { infof(data, "ECH: setting public_name not supported with BoringSSL"); return CURLE_SSL_CONNECT_ERROR; @@ -3960,7 +3952,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, return CURLE_SSL_CONNECT_ERROR; } } -# endif /* not BORING */ +# endif /* OPENSSL_IS_BORINGSSL || OPENSSL_IS_AWSLC */ if(trying_ech_now && SSL_set_min_proto_version(octx->ssl, TLS1_3_VERSION) != 1) { infof(data, "ECH: cannot force TLSv1.3 [ERROR]"); @@ -4071,7 +4063,7 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl, CURLcode result = CURLE_OK; size_t rcl = 0; int rv = 1; -# ifndef OPENSSL_IS_BORINGSSL +# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) char *inner = NULL; unsigned char *rcs = NULL; char *outer = NULL; @@ -4086,7 +4078,7 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl, /* nothing to trace if not doing ECH */ if(!ECH_ENABLED(data)) return; -# ifndef OPENSSL_IS_BORINGSSL +# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) rv = SSL_ech_get_retry_config(ssl, &rcs, &rcl); # else SSL_get0_ech_retry_configs(ssl, &rcs, &rcl); @@ -4103,23 +4095,23 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl, if(!result && b64str) infof(data, "ECH: retry_configs %s", b64str); free(b64str); -# ifndef OPENSSL_IS_BORINGSSL +# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) rv = SSL_ech_get_status(ssl, &inner, &outer); infof(data, "ECH: retry_configs for %s from %s, %d %d", inner ? inner : "NULL", outer ? outer : "NULL", reason, rv); -#else +# else rv = SSL_ech_accepted(ssl); servername_type = SSL_get_servername_type(ssl); inner = SSL_get_servername(ssl, servername_type); SSL_get0_ech_name_override(ssl, &outer, &out_name_len); - /* TODO: get the inner from boring */ + /* TODO: get the inner from BoringSSL */ infof(data, "ECH: retry_configs for %s from %s, %d %d", inner ? inner : "NULL", outer ? outer : "NULL", reason, rv); -#endif +# endif } else infof(data, "ECH: no retry_configs (rv = %d)", rv); -# ifndef OPENSSL_IS_BORINGSSL +# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) OPENSSL_free((void *)rcs); # endif return; @@ -4220,14 +4212,11 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, lerr = SSL_get_verify_result(octx->ssl); if(lerr != X509_V_OK) { ssl_config->certverifyresult = lerr; - msnprintf(error_buffer, sizeof(error_buffer), - "SSL certificate problem: %s", - X509_verify_cert_error_string(lerr)); + failf(data, "SSL certificate problem: %s", + X509_verify_cert_error_string(lerr)); } - else { + else failf(data, "%s", "SSL certificate verification failed"); - return result; - } } #if defined(SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED) /* SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED is only available on @@ -4243,7 +4232,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, #endif #ifdef USE_ECH else if((lib == ERR_LIB_SSL) && -# ifndef OPENSSL_IS_BORINGSSL +# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) (reason == SSL_R_ECH_REQUIRED)) { # else (reason == SSL_R_ECH_REJECTED)) { @@ -4278,7 +4267,6 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, failf(data, OSSL_PACKAGE " SSL_connect: %s in connection to %s:%d ", extramsg[0] ? extramsg : SSL_ERROR_to_str(detail), connssl->peer.hostname, connssl->peer.port); - return result; } return result; @@ -4309,7 +4297,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, OBJ_nid2sn(psigtype_nid)); #ifdef USE_ECH -# ifndef OPENSSL_IS_BORINGSSL +# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) if(ECH_ENABLED(data)) { char *inner = NULL, *outer = NULL; const char *status = NULL; @@ -4367,7 +4355,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, else { infof(data, "ECH: result: status is not attempted"); } -# endif /* BORING */ +# endif /* !OPENSSL_IS_BORINGSSL && !OPENSSL_IS_AWSLC */ #endif /* USE_ECH */ #ifdef HAS_ALPN diff --git a/deps/curl/lib/vtls/schannel.c b/deps/curl/lib/vtls/schannel.c index 2085f709467..f4bbe4e8325 100644 --- a/deps/curl/lib/vtls/schannel.c +++ b/deps/curl/lib/vtls/schannel.c @@ -451,11 +451,6 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path, } #endif -static bool algo(const char *check, char *namep, size_t nlen) -{ - return (strlen(check) == nlen) && !strncmp(check, namep, nlen); -} - static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, struct Curl_easy *data) @@ -781,187 +776,14 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, curlx_verify_windows_version(10, 0, 17763, PLATFORM_WINNT, VERSION_GREATER_THAN_EQUAL)) { - char *ciphers13 = 0; - - bool disable_aes_gcm_sha384 = FALSE; - bool disable_aes_gcm_sha256 = FALSE; - bool disable_chacha_poly = FALSE; - bool disable_aes_ccm_8_sha256 = FALSE; - bool disable_aes_ccm_sha256 = FALSE; - SCH_CREDENTIALS credentials = { 0 }; TLS_PARAMETERS tls_parameters = { 0 }; - CRYPTO_SETTINGS crypto_settings[4] = { { 0 } }; - UNICODE_STRING blocked_ccm_modes[1] = { { 0 } }; - UNICODE_STRING blocked_gcm_modes[1] = { { 0 } }; - - int crypto_settings_idx = 0; - - - /* If TLS 1.3 ciphers are explicitly listed, then - * disable all the ciphers and re-enable which - * ciphers the user has provided. - */ - ciphers13 = conn_config->cipher_list13; - if(ciphers13) { - const int remaining_ciphers = 5; - - /* detect which remaining ciphers to enable - and then disable everything else. - */ - - char *startCur = ciphers13; - int algCount = 0; - char *nameEnd; - - disable_aes_gcm_sha384 = TRUE; - disable_aes_gcm_sha256 = TRUE; - disable_chacha_poly = TRUE; - disable_aes_ccm_8_sha256 = TRUE; - disable_aes_ccm_sha256 = TRUE; - - while(startCur && (0 != *startCur) && (algCount < remaining_ciphers)) { - size_t n; - char *namep; - nameEnd = strchr(startCur, ':'); - n = nameEnd ? (size_t)(nameEnd - startCur) : strlen(startCur); - namep = startCur; - - if(disable_aes_gcm_sha384 && - algo("TLS_AES_256_GCM_SHA384", namep, n)) { - disable_aes_gcm_sha384 = FALSE; - } - else if(disable_aes_gcm_sha256 - && algo("TLS_AES_128_GCM_SHA256", namep, n)) { - disable_aes_gcm_sha256 = FALSE; - } - else if(disable_chacha_poly - && algo("TLS_CHACHA20_POLY1305_SHA256", namep, n)) { - disable_chacha_poly = FALSE; - } - else if(disable_aes_ccm_8_sha256 - && algo("TLS_AES_128_CCM_8_SHA256", namep, n)) { - disable_aes_ccm_8_sha256 = FALSE; - } - else if(disable_aes_ccm_sha256 - && algo("TLS_AES_128_CCM_SHA256", namep, n)) { - disable_aes_ccm_sha256 = FALSE; - } - else { - failf(data, "schannel: Unknown TLS 1.3 cipher: %.*s", (int)n, namep); - return CURLE_SSL_CIPHER; - } - - startCur = nameEnd; - if(startCur) - startCur++; - - algCount++; - } - } - - if(disable_aes_gcm_sha384 && disable_aes_gcm_sha256 - && disable_chacha_poly && disable_aes_ccm_8_sha256 - && disable_aes_ccm_sha256) { - failf(data, "schannel: All available TLS 1.3 ciphers were disabled"); - return CURLE_SSL_CIPHER; - } - - /* Disable TLS_AES_128_CCM_8_SHA256 and/or TLS_AES_128_CCM_SHA256 */ - if(disable_aes_ccm_8_sha256 || disable_aes_ccm_sha256) { - /* - Disallow AES_CCM algorithm. - */ - blocked_ccm_modes[0].Length = sizeof(BCRYPT_CHAIN_MODE_CCM); - blocked_ccm_modes[0].MaximumLength = sizeof(BCRYPT_CHAIN_MODE_CCM); - blocked_ccm_modes[0].Buffer = (PWSTR)BCRYPT_CHAIN_MODE_CCM; - - crypto_settings[crypto_settings_idx].eAlgorithmUsage = - TlsParametersCngAlgUsageCipher; - crypto_settings[crypto_settings_idx].rgstrChainingModes = - blocked_ccm_modes; - crypto_settings[crypto_settings_idx].cChainingModes = - ARRAYSIZE(blocked_ccm_modes); - crypto_settings[crypto_settings_idx].strCngAlgId.Length = - sizeof(BCRYPT_AES_ALGORITHM); - crypto_settings[crypto_settings_idx].strCngAlgId.MaximumLength = - sizeof(BCRYPT_AES_ALGORITHM); - crypto_settings[crypto_settings_idx].strCngAlgId.Buffer = - (PWSTR)BCRYPT_AES_ALGORITHM; - - /* only disabling one of the CCM modes */ - if(disable_aes_ccm_8_sha256 != disable_aes_ccm_sha256) { - if(disable_aes_ccm_8_sha256) - crypto_settings[crypto_settings_idx].dwMinBitLength = 128; - else /* disable_aes_ccm_sha256 */ - crypto_settings[crypto_settings_idx].dwMaxBitLength = 64; - } - - crypto_settings_idx++; - } - - /* Disable TLS_AES_256_GCM_SHA384 and/or TLS_AES_128_GCM_SHA256 */ - if(disable_aes_gcm_sha384 || disable_aes_gcm_sha256) { - - /* - Disallow AES_GCM algorithm - */ - blocked_gcm_modes[0].Length = sizeof(BCRYPT_CHAIN_MODE_GCM); - blocked_gcm_modes[0].MaximumLength = sizeof(BCRYPT_CHAIN_MODE_GCM); - blocked_gcm_modes[0].Buffer = (PWSTR)BCRYPT_CHAIN_MODE_GCM; - - /* if only one is disabled, then explicitly disable the - digest cipher suite (sha384 or sha256) */ - if(disable_aes_gcm_sha384 != disable_aes_gcm_sha256) { - crypto_settings[crypto_settings_idx].eAlgorithmUsage = - TlsParametersCngAlgUsageDigest; - crypto_settings[crypto_settings_idx].strCngAlgId.Length = - sizeof(disable_aes_gcm_sha384 ? - BCRYPT_SHA384_ALGORITHM : BCRYPT_SHA256_ALGORITHM); - crypto_settings[crypto_settings_idx].strCngAlgId.MaximumLength = - sizeof(disable_aes_gcm_sha384 ? - BCRYPT_SHA384_ALGORITHM : BCRYPT_SHA256_ALGORITHM); - crypto_settings[crypto_settings_idx].strCngAlgId.Buffer = - (PWSTR)(disable_aes_gcm_sha384 ? - BCRYPT_SHA384_ALGORITHM : BCRYPT_SHA256_ALGORITHM); - } - else { /* Disable both AES_GCM ciphers */ - crypto_settings[crypto_settings_idx].eAlgorithmUsage = - TlsParametersCngAlgUsageCipher; - crypto_settings[crypto_settings_idx].strCngAlgId.Length = - sizeof(BCRYPT_AES_ALGORITHM); - crypto_settings[crypto_settings_idx].strCngAlgId.MaximumLength = - sizeof(BCRYPT_AES_ALGORITHM); - crypto_settings[crypto_settings_idx].strCngAlgId.Buffer = - (PWSTR)BCRYPT_AES_ALGORITHM; - } - - crypto_settings[crypto_settings_idx].rgstrChainingModes = - blocked_gcm_modes; - crypto_settings[crypto_settings_idx].cChainingModes = 1; - - crypto_settings_idx++; - } - - /* - Disable ChaCha20-Poly1305. - */ - if(disable_chacha_poly) { - crypto_settings[crypto_settings_idx].eAlgorithmUsage = - TlsParametersCngAlgUsageCipher; - crypto_settings[crypto_settings_idx].strCngAlgId.Length = - sizeof(BCRYPT_CHACHA20_POLY1305_ALGORITHM); - crypto_settings[crypto_settings_idx].strCngAlgId.MaximumLength = - sizeof(BCRYPT_CHACHA20_POLY1305_ALGORITHM); - crypto_settings[crypto_settings_idx].strCngAlgId.Buffer = - (PWSTR)BCRYPT_CHACHA20_POLY1305_ALGORITHM; - crypto_settings_idx++; - } + CRYPTO_SETTINGS crypto_settings[1] = { { 0 } }; tls_parameters.pDisabledCrypto = crypto_settings; /* The number of blocked suites */ - tls_parameters.cDisabledCrypto = (DWORD)crypto_settings_idx; + tls_parameters.cDisabledCrypto = (DWORD)0; credentials.pTlsParameters = &tls_parameters; credentials.cTlsParameters = 1; @@ -986,9 +808,8 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, &backend->cred->time_stamp); } else { - /* Pre-Windows 10 1809 or the user set a legacy algorithm list. Although MS - does not document it, currently Schannel will not negotiate TLS 1.3 when - SCHANNEL_CRED is used. */ + /* Pre-Windows 10 1809 or the user set a legacy algorithm list. + Schannel will not negotiate TLS 1.3 when SCHANNEL_CRED is used. */ ALG_ID algIds[NUM_CIPHERS]; char *ciphers = conn_config->cipher_list; SCHANNEL_CRED schannel_cred = { 0 }; @@ -998,16 +819,10 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, if(ciphers) { if((enabled_protocols & SP_PROT_TLS1_3_CLIENT)) { - infof(data, "schannel: WARNING: This version of Schannel may " - "negotiate a less-secure TLS version than TLS 1.3 because the " + infof(data, "schannel: WARNING: This version of Schannel " + "negotiates a less-secure TLS version than TLS 1.3 because the " "user set an algorithm cipher list."); } - if(conn_config->cipher_list13) { - failf(data, "schannel: This version of Schannel does not support " - "setting an algorithm cipher list and TLS 1.3 cipher list at " - "the same time"); - return CURLE_SSL_CIPHER; - } result = set_ssl_ciphers(&schannel_cred, ciphers, algIds); if(CURLE_OK != result) { failf(data, "schannel: Failed setting algorithm cipher list"); @@ -2974,7 +2789,6 @@ const struct Curl_ssl Curl_ssl_schannel = { #ifndef CURL_WINDOWS_UWP SSLSUPP_PINNEDPUBKEY | #endif - SSLSUPP_TLS13_CIPHERSUITES | SSLSUPP_CA_CACHE | SSLSUPP_HTTPS_PROXY | SSLSUPP_CIPHER_LIST, diff --git a/deps/curl/lib/vtls/schannel_verify.c b/deps/curl/lib/vtls/schannel_verify.c index 4b52b8e8a49..fede3908feb 100644 --- a/deps/curl/lib/vtls/schannel_verify.c +++ b/deps/curl/lib/vtls/schannel_verify.c @@ -554,7 +554,7 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf, } } - if(p->size) { + if(p->size && alt_name_info) { for(i = 0; i < alt_name_info->cAltEntry; ++i) { PCERT_ALT_NAME_ENTRY entry = &alt_name_info->rgAltEntry[i]; if(entry->dwAltNameChoice == CERT_ALT_NAME_IP_ADDRESS) { @@ -571,7 +571,6 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf, } } } - else { /* Determine the size of the string needed for the cert hostname */ len = cert_get_name_string(data, pCertContextServer, diff --git a/deps/curl/lib/vtls/sectransp.c b/deps/curl/lib/vtls/sectransp.c index 022c467f014..c6a1c73dcf8 100644 --- a/deps/curl/lib/vtls/sectransp.c +++ b/deps/curl/lib/vtls/sectransp.c @@ -354,8 +354,8 @@ CF_INLINE void GetDarwinVersionNumber(int *major, int *minor) } /* Parse the version: */ - os_version_major = strtok_r(os_version, ".", &tok_buf); - os_version_minor = strtok_r(NULL, ".", &tok_buf); + os_version_major = Curl_strtok_r(os_version, ".", &tok_buf); + os_version_minor = Curl_strtok_r(NULL, ".", &tok_buf); *major = atoi(os_version_major); *minor = atoi(os_version_minor); free(os_version); diff --git a/deps/curl/lib/vtls/wolfssl.c b/deps/curl/lib/vtls/wolfssl.c index 0d74b3e763d..3394cb2748c 100644 --- a/deps/curl/lib/vtls/wolfssl.c +++ b/deps/curl/lib/vtls/wolfssl.c @@ -33,8 +33,8 @@ #ifdef USE_WOLFSSL #define WOLFSSL_OPTIONS_IGNORE_SYS -#include #include +#include #if LIBWOLFSSL_VERSION_HEX < 0x03004006 /* wolfSSL 3.4.6 (2015) */ #error "wolfSSL version should be at least 3.4.6" From 06d6c844e0581d33155f3832fe3e29ab3cc53ced Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 2 Jan 2025 13:20:55 +0100 Subject: [PATCH 16/19] lib,src: fix a couple of linting issues --- agents/grpc/src/grpc_agent.cc | 3 ++- test/addons/nsolid-metrics/nsolid-metrics.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index d67dc5cdc61..2dc945807ef 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -1046,7 +1046,8 @@ int GrpcAgent::config(const json& config) { } } - std::shared_ptr client = OtlpGrpcClientFactory::Create(opts); + std::shared_ptr client = + OtlpGrpcClientFactory::Create(opts); nsolid_service_stub_ = GrpcClient::MakeNSolidServiceStub(opts); { diff --git a/test/addons/nsolid-metrics/nsolid-metrics.js b/test/addons/nsolid-metrics/nsolid-metrics.js index 8a57aaab7d9..4dfc73bf643 100644 --- a/test/addons/nsolid-metrics/nsolid-metrics.js +++ b/test/addons/nsolid-metrics/nsolid-metrics.js @@ -25,7 +25,7 @@ if (!isMainThread) { process.on('beforeExit', mustCall(() => { assert.strictEqual(binding.getCbCntr(), wkr_count); - assert.ok(binding.getCbCntrGone() < wkr_count/ 2); + assert.ok(binding.getCbCntrGone() < wkr_count / 2); assert.strictEqual(binding.getCbCntrLambda(), wkr_count); })); From aa3c4d7ecc21e297129a9af15cec200c82d50dc2 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 9 Jan 2025 16:47:34 +0100 Subject: [PATCH 17/19] agents: don't send exit if grpc agent unconfigured PR-URL: https://github.com/nodesource/nsolid/pull/248 Reviewed-By: Rafael Gonzaga --- agents/grpc/src/grpc_agent.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index 2dc945807ef..da4740d068c 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -1227,7 +1227,9 @@ void GrpcAgent::do_start() { } void GrpcAgent::do_stop() { - if (!unauthorized_) { + // Don't try to send the exit event when grpc connection wasn't authorized or + // the agent wasn't fully configured. + if (!unauthorized_ && nsolid_service_stub_) { send_exit(); } From 065eee5d2ed99d380e4fa9badd2dcdab4b466e33 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 9 Jan 2025 13:57:12 +0100 Subject: [PATCH 18/19] agents: fix grpc insecure opt initialization `OtlpGrpcClientOptions.use_ssl_credentials` is not initialized by default to `false` as it happens with all their children. Make sure it is otherwise it can produce undesired behaviour. PR-URL: https://github.com/nodesource/nsolid/pull/247 Reviewed-By: Rafael Gonzaga --- agents/grpc/src/grpc_agent.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index da4740d068c..e8cbc47102b 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -1037,8 +1037,8 @@ int GrpcAgent::config(const json& config) { opts.endpoint = endpoint; opts.metadata = {{"nsolid-agent-id", agent_id_}, {"nsolid-saas", saas()}}; + opts.use_ssl_credentials = !insecure; if (!insecure) { - opts.use_ssl_credentials = true; if (!custom_certs_.empty()) { opts.ssl_credentials_cacert_as_string = custom_certs_; } else { From 28393b2cbf47b8528a61387eee8dcd398aa649fc Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Wed, 4 Dec 2024 19:38:01 +0100 Subject: [PATCH 19/19] lib: fix crash if invalid SaaS token MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And in general, make the `saas` config option handling more robust and consistent. PR-URL: https://github.com/nodesource/nsolid/pull/235 Reviewed-By: Juan José Arboleda --- lib/nsolid.js | 34 ++++++-- test/parallel/test-nsolid-config-saas.js | 98 ++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 8 deletions(-) diff --git a/lib/nsolid.js b/lib/nsolid.js index 52b434d4344..94ebaf1871e 100644 --- a/lib/nsolid.js +++ b/lib/nsolid.js @@ -684,16 +684,10 @@ function updateConfig(config = {}) { throw new ERR_INVALID_ARG_TYPE(`config.${key}`, 'string', value); nsolidConfig[key] = value; - if (key === 'command') { - nsolidConfig.saas = undefined; - } } else if (key === 'statsd' || key === 'grpc') { // The statsd variable can now be set to null to stop the statsd agent. nsolidConfig[key] = value; } - } else if (key === 'saas' && !config.command) { - nsolidConfig.saas = config.saas; - nsolidConfig.command = parseSaasEnvVar(nsolidConfig.saas, 0); } else if (key === 'otlp') { const otlp = parseOTLPType(config.otlp); if (otlp !== nsolidConfig.otlp) { @@ -713,6 +707,25 @@ function updateConfig(config = {}) { nsolidConfig.otlp = null; } + if (nsolidConfig.saas) { + if (!config.command) { + nsolidConfig.command = undefined; + } + + if (nsolidConfig.command) { + nsolidConfig.saas = undefined; + } else { + const url = parseSaasEnvVar(nsolidConfig.saas, 0); + if (!url) { + nsolidConfig.saas = undefined; + } else if (!nsolidConfig.grpc) { + nsolidConfig.command = url; + } else { + nsolidConfig.grpc = '' + config.grpc; + } + } + } + if (nsolidConfig.grpc && !nsolidConfig.saas) { // Make sure it's a valid URL otherwise it might crash in the grpc++ // URLParser implementation @@ -777,8 +790,13 @@ function initializeConfig(nsolidConfig) { if (nsolidConfig.saas) { if (nsolidConfig.command) { nsolidConfig.saas = undefined; - } else if (!nsolidConfig.grpc) { - nsolidConfig.command = parseSaasEnvVar(nsolidConfig.saas, 0); + } else { + const url = parseSaasEnvVar(nsolidConfig.saas, 0); + if (!url) { + nsolidConfig.saas = undefined; + } else if (!nsolidConfig.grpc) { + nsolidConfig.command = url; + } } } diff --git a/test/parallel/test-nsolid-config-saas.js b/test/parallel/test-nsolid-config-saas.js index 4626ac22415..11f25532d60 100644 --- a/test/parallel/test-nsolid-config-saas.js +++ b/test/parallel/test-nsolid-config-saas.js @@ -9,6 +9,7 @@ const PORT = 12345; const saasToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.example.org:9001'; const saasCommand = 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.example.org:9001'; +const invalidSaasToken = 'invalid.example.org:9001'; if (process.config.variables.asan) common.skip('incorrect leak reporting in curl.'); @@ -171,6 +172,85 @@ function execProc7() { }); } +function execProc8() { + let output = ''; + const proc = spawn(process.execPath, + [ __filename, 'child1' ], + { + env: { + NSOLID_SAAS: invalidSaasToken + } + }); + proc.stdout.on('data', (d) => { + output += d; + }); + + proc.on('close', (code) => { + assert.strictEqual(code, 0); + const config = JSON.parse(output); + assert.strictEqual(config.command, undefined); + assert.strictEqual(config.saas, undefined); + }); +} + +function execProc9() { + let output = ''; + const proc = spawn(process.execPath, + [ __filename, 'child1' ], + { + env: { + NSOLID_SAAS: invalidSaasToken, + NSOLID_GRPC: PORT, + } + }); + proc.stdout.on('data', (d) => { + output += d; + }); + + proc.on('close', (code) => { + assert.strictEqual(code, 0); + const config = JSON.parse(output); + assert.strictEqual(config.command, undefined); + assert.strictEqual(config.grpc, `localhost:${PORT}`); + assert.strictEqual(config.saas, undefined); + }); +} + +function execProc10() { + let output = ''; + const proc = spawn(process.execPath, + [ __filename, 'child5' ]); + proc.stdout.on('data', (d) => { + output += d; + }); + + proc.on('close', (code) => { + assert.strictEqual(code, 0); + const config = JSON.parse(output); + assert.strictEqual(config.command, undefined); + assert.strictEqual(config.grpc, `localhost:${PORT}`); + assert.strictEqual(config.saas, undefined); + }); +} + +function execProc11() { + let output = ''; + const proc = spawn(process.execPath, + [ __filename, 'child6' ]); + proc.stdout.on('data', (d) => { + output += d; + }); + + proc.on('close', (code) => { + assert.strictEqual(code, 0); + const config = JSON.parse(output); + assert.strictEqual(config.command, undefined); + assert.strictEqual(config.grpc, `${PORT}`); + assert.strictEqual(config.saas, saasToken); + }); +} + + switch (process.argv[2]) { case 'child1': process.stdout.write(JSON.stringify(nsolid.config)); @@ -201,6 +281,20 @@ switch (process.argv[2]) { process.stdout.write(JSON.stringify(out)); } break; + case 'child5': + nsolid.start({ + grpc: PORT, + saas: invalidSaasToken + }); + process.stdout.write(JSON.stringify(nsolid.config)); + break; + case 'child6': + nsolid.start({ + grpc: PORT, + saas: saasToken + }); + process.stdout.write(JSON.stringify(nsolid.config)); + break; default: execProc1(); execProc2(); @@ -209,4 +303,8 @@ switch (process.argv[2]) { execProc5(); execProc6(); execProc7(); + execProc8(); + execProc9(); + execProc10(); + execProc11(); }