From 2b59dad6bfff7f4220532fc8abebcbfec75edba2 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Fri, 22 Mar 2024 16:27:46 -0700 Subject: [PATCH 01/11] add `data` field to the Event interface --- experimental/packages/api-events/package.json | 3 ++- experimental/packages/api-events/src/types/Event.ts | 7 +++++++ experimental/packages/api-events/tsconfig.esm.json | 3 +++ experimental/packages/api-events/tsconfig.esnext.json | 3 +++ experimental/packages/api-events/tsconfig.json | 3 +++ experimental/packages/api-logs/src/types/LogRecord.ts | 2 +- 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/experimental/packages/api-events/package.json b/experimental/packages/api-events/package.json index f1b40f080e..2c40d47717 100644 --- a/experimental/packages/api-events/package.json +++ b/experimental/packages/api-events/package.json @@ -61,7 +61,8 @@ "access": "public" }, "dependencies": { - "@opentelemetry/api": "^1.0.0" + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api-logs": "0.49.1" }, "devDependencies": { "@types/mocha": "10.0.6", diff --git a/experimental/packages/api-events/src/types/Event.ts b/experimental/packages/api-events/src/types/Event.ts index 03e4ef89db..8c493cb0c2 100644 --- a/experimental/packages/api-events/src/types/Event.ts +++ b/experimental/packages/api-events/src/types/Event.ts @@ -15,6 +15,7 @@ */ import { Attributes } from '@opentelemetry/api'; +import { LogAttributeValue } from '@opentelemetry/api-logs'; export interface Event { /** @@ -27,6 +28,12 @@ export interface Event { */ name: string; + /** + * Attributes that describe the event. + * Intended to be used by instrumentation libraries. + */ + data?: LogAttributeValue; + /** * Additional attributes that describe the event. */ diff --git a/experimental/packages/api-events/tsconfig.esm.json b/experimental/packages/api-events/tsconfig.esm.json index f0383c0042..91cc36db7a 100644 --- a/experimental/packages/api-events/tsconfig.esm.json +++ b/experimental/packages/api-events/tsconfig.esm.json @@ -11,6 +11,9 @@ "references": [ { "path": "../../../api" + }, + { + "path": "../api-logs" } ] } diff --git a/experimental/packages/api-events/tsconfig.esnext.json b/experimental/packages/api-events/tsconfig.esnext.json index 218899ff2d..80e34599a9 100644 --- a/experimental/packages/api-events/tsconfig.esnext.json +++ b/experimental/packages/api-events/tsconfig.esnext.json @@ -11,6 +11,9 @@ "references": [ { "path": "../../../api" + }, + { + "path": "../api-logs" } ] } diff --git a/experimental/packages/api-events/tsconfig.json b/experimental/packages/api-events/tsconfig.json index 5849e79c03..40ca71c181 100644 --- a/experimental/packages/api-events/tsconfig.json +++ b/experimental/packages/api-events/tsconfig.json @@ -12,6 +12,9 @@ "references": [ { "path": "../../../api" + }, + { + "path": "../api-logs" } ] } diff --git a/experimental/packages/api-logs/src/types/LogRecord.ts b/experimental/packages/api-logs/src/types/LogRecord.ts index 69dd14f7cb..060b35777e 100644 --- a/experimental/packages/api-logs/src/types/LogRecord.ts +++ b/experimental/packages/api-logs/src/types/LogRecord.ts @@ -73,7 +73,7 @@ export interface LogRecord { /** * A value containing the body of the log record. */ - body?: string; + body?: LogAttributeValue; /** * Attributes that define the log record. From 1342cd050cafbe98b4b883035b2d37bb3247f9ab Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Fri, 22 Mar 2024 16:49:52 -0700 Subject: [PATCH 02/11] updated body field in the Logs SDK --- experimental/packages/sdk-logs/src/LogRecord.ts | 8 ++++---- .../packages/sdk-logs/src/export/ReadableLogRecord.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/experimental/packages/sdk-logs/src/LogRecord.ts b/experimental/packages/sdk-logs/src/LogRecord.ts index d827c7fa1d..7667b73550 100644 --- a/experimental/packages/sdk-logs/src/LogRecord.ts +++ b/experimental/packages/sdk-logs/src/LogRecord.ts @@ -26,7 +26,7 @@ import type { IResource } from '@opentelemetry/resources'; import type { ReadableLogRecord } from './export/ReadableLogRecord'; import type { LogRecordLimits } from './types'; -import { LogAttributes } from '@opentelemetry/api-logs'; +import { LogAttributes, LogAttributeValue } from '@opentelemetry/api-logs'; import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState'; export class LogRecord implements ReadableLogRecord { @@ -38,7 +38,7 @@ export class LogRecord implements ReadableLogRecord { readonly attributes: logsAPI.LogAttributes = {}; private _severityText?: string; private _severityNumber?: logsAPI.SeverityNumber; - private _body?: string; + private _body?: LogAttributeValue; private totalAttributesCount: number = 0; private _isReadonly: boolean = false; @@ -64,13 +64,13 @@ export class LogRecord implements ReadableLogRecord { return this._severityNumber; } - set body(body: string | undefined) { + set body(body: LogAttributeValue | undefined) { if (this._isLogRecordReadonly()) { return; } this._body = body; } - get body(): string | undefined { + get body(): LogAttributeValue | undefined { return this._body; } diff --git a/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts b/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts index 2dc3ece865..d036a17ef2 100644 --- a/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts +++ b/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts @@ -17,7 +17,7 @@ import type { IResource } from '@opentelemetry/resources'; import type { HrTime, SpanContext } from '@opentelemetry/api'; import type { InstrumentationScope } from '@opentelemetry/core'; -import type { LogAttributes, SeverityNumber } from '@opentelemetry/api-logs'; +import type { LogAttributeValue, LogAttributes, SeverityNumber } from '@opentelemetry/api-logs'; export interface ReadableLogRecord { readonly hrTime: HrTime; @@ -25,7 +25,7 @@ export interface ReadableLogRecord { readonly spanContext?: SpanContext; readonly severityText?: string; readonly severityNumber?: SeverityNumber; - readonly body?: string; + readonly body?: LogAttributeValue; readonly resource: IResource; readonly instrumentationScope: InstrumentationScope; readonly attributes: LogAttributes; From a302e9e1510cbd1552cf22777d064fc3776beec9 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Fri, 22 Mar 2024 16:53:01 -0700 Subject: [PATCH 03/11] updated changelog to breaking change --- experimental/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 62588e6877..b8153427b9 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to experimental packages in this project will be documented * was used internally to keep track of the compression to use but was unintentionally exposed to the users. It allowed to read and write the value, writing, however, would have no effect. * feat(api-events)!: removed domain from the Events API [#4569](https://github.com/open-telemetry/opentelemetry-js/pull/4569) * fix(events-api)!: renamed EventEmitter to EventLogger in the Events API [#4569](https://github.com/open-telemetry/opentelemetry-js/pull/4568) +* feat(api-events)!: added data field to the Event interface [4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) ### :rocket: (Enhancement) From f0cc15e1bb30f225fdd2489bdb500653bcbdcc77 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Fri, 22 Mar 2024 16:57:32 -0700 Subject: [PATCH 04/11] lint --- .../packages/sdk-logs/src/export/ReadableLogRecord.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts b/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts index d036a17ef2..c8fe8bc5f4 100644 --- a/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts +++ b/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts @@ -17,7 +17,11 @@ import type { IResource } from '@opentelemetry/resources'; import type { HrTime, SpanContext } from '@opentelemetry/api'; import type { InstrumentationScope } from '@opentelemetry/core'; -import type { LogAttributeValue, LogAttributes, SeverityNumber } from '@opentelemetry/api-logs'; +import type { + LogAttributeValue, + LogAttributes, + SeverityNumber, +} from '@opentelemetry/api-logs'; export interface ReadableLogRecord { readonly hrTime: HrTime; From 0053c009b20472cfb96e46a1d62ced6fa8ef29f3 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Mon, 25 Mar 2024 09:52:43 -0700 Subject: [PATCH 05/11] added dedicated type for event data field --- experimental/packages/api-events/src/types/Event.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/experimental/packages/api-events/src/types/Event.ts b/experimental/packages/api-events/src/types/Event.ts index 8c493cb0c2..0dfbddbd68 100644 --- a/experimental/packages/api-events/src/types/Event.ts +++ b/experimental/packages/api-events/src/types/Event.ts @@ -17,6 +17,8 @@ import { Attributes } from '@opentelemetry/api'; import { LogAttributeValue } from '@opentelemetry/api-logs'; +export type EventDataValue = LogAttributeValue; + export interface Event { /** * The time when the event occurred as UNIX Epoch time in nanoseconds. @@ -29,10 +31,10 @@ export interface Event { name: string; /** - * Attributes that describe the event. + * Data that describes the event. * Intended to be used by instrumentation libraries. */ - data?: LogAttributeValue; + data?: EventDataValue; /** * Additional attributes that describe the event. From 0149ed24f89f52f43ff199286f36961db07528c3 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Thu, 28 Mar 2024 08:16:24 -0700 Subject: [PATCH 06/11] added AnyValue and AnyValueMap types for Event data --- api/CHANGELOG.md | 1 + api/src/common/Attributes.ts | 12 ++++++++++++ api/src/index.ts | 7 ++++++- experimental/packages/api-events/src/types/Event.ts | 7 ++----- .../packages/api-logs/src/types/LogRecord.ts | 8 +++----- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index f33bcbaddf..1d3218e973 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ## Unreleased ### :boom: Breaking Change +* feat(api)!: add AnyValue and AnyValueMap types [#4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) ### :rocket: (Enhancement) diff --git a/api/src/common/Attributes.ts b/api/src/common/Attributes.ts index 53a8166d84..d02187302b 100644 --- a/api/src/common/Attributes.ts +++ b/api/src/common/Attributes.ts @@ -35,3 +35,15 @@ export type AttributeValue = | Array | Array | Array; + +/** + * AnyValueMap is a map from string to AnyValue (attribute value or a nested map) + */ +export interface AnyValueMap { + [attributeKey: string]: AnyValue | undefined; +} + +/** + * AnyValue is a either an attribute value or a map of AnyValue(s) + */ +export type AnyValue = AttributeValue | AnyValueMap; diff --git a/api/src/index.ts b/api/src/index.ts index c5dbe1685b..108e56c6ee 100644 --- a/api/src/index.ts +++ b/api/src/index.ts @@ -18,7 +18,12 @@ export { BaggageEntry, BaggageEntryMetadata, Baggage } from './baggage/types'; export { baggageEntryMetadataFromString } from './baggage/utils'; export { Exception } from './common/Exception'; export { HrTime, TimeInput } from './common/Time'; -export { Attributes, AttributeValue } from './common/Attributes'; +export { + Attributes, + AttributeValue, + AnyValue, + AnyValueMap, +} from './common/Attributes'; // Context APIs export { createContextKey, ROOT_CONTEXT } from './context/context'; diff --git a/experimental/packages/api-events/src/types/Event.ts b/experimental/packages/api-events/src/types/Event.ts index 0dfbddbd68..00f68aea14 100644 --- a/experimental/packages/api-events/src/types/Event.ts +++ b/experimental/packages/api-events/src/types/Event.ts @@ -14,10 +14,7 @@ * limitations under the License. */ -import { Attributes } from '@opentelemetry/api'; -import { LogAttributeValue } from '@opentelemetry/api-logs'; - -export type EventDataValue = LogAttributeValue; +import { AnyValue, Attributes } from '@opentelemetry/api'; export interface Event { /** @@ -34,7 +31,7 @@ export interface Event { * Data that describes the event. * Intended to be used by instrumentation libraries. */ - data?: EventDataValue; + data?: AnyValue; /** * Additional attributes that describe the event. diff --git a/experimental/packages/api-logs/src/types/LogRecord.ts b/experimental/packages/api-logs/src/types/LogRecord.ts index 060b35777e..41c2f2c377 100644 --- a/experimental/packages/api-logs/src/types/LogRecord.ts +++ b/experimental/packages/api-logs/src/types/LogRecord.ts @@ -14,12 +14,10 @@ * limitations under the License. */ -import { AttributeValue, Context, TimeInput } from '@opentelemetry/api'; +import { AnyValue, AnyValueMap, Context, TimeInput } from '@opentelemetry/api'; -export type LogAttributeValue = AttributeValue | LogAttributes; -export interface LogAttributes { - [attributeKey: string]: LogAttributeValue | undefined; -} +export type LogAttributeValue = AnyValue; +export type LogAttributes = AnyValueMap; export enum SeverityNumber { UNSPECIFIED = 0, From a33b8e8a23e9bc864fa2064ee5eb1c7553cb833a Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Thu, 28 Mar 2024 08:21:04 -0700 Subject: [PATCH 07/11] changed body type to LogBody --- experimental/packages/api-logs/src/types/LogRecord.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/experimental/packages/api-logs/src/types/LogRecord.ts b/experimental/packages/api-logs/src/types/LogRecord.ts index 41c2f2c377..f4e8b20038 100644 --- a/experimental/packages/api-logs/src/types/LogRecord.ts +++ b/experimental/packages/api-logs/src/types/LogRecord.ts @@ -16,7 +16,7 @@ import { AnyValue, AnyValueMap, Context, TimeInput } from '@opentelemetry/api'; -export type LogAttributeValue = AnyValue; +export type LogBody = AnyValue; export type LogAttributes = AnyValueMap; export enum SeverityNumber { @@ -71,7 +71,7 @@ export interface LogRecord { /** * A value containing the body of the log record. */ - body?: LogAttributeValue; + body?: LogBody; /** * Attributes that define the log record. From e5fa00916689c9e35f0523cfd173cce5fbb727ee Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Thu, 28 Mar 2024 08:35:35 -0700 Subject: [PATCH 08/11] markdown lint --- api/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index 1d3218e973..7fd5ea06e7 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ## Unreleased ### :boom: Breaking Change + * feat(api)!: add AnyValue and AnyValueMap types [#4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) ### :rocket: (Enhancement) From 60e58105ea00f3f418a72dcaa94b5d816acc0623 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Thu, 28 Mar 2024 08:52:09 -0700 Subject: [PATCH 09/11] updated Logs SDK --- experimental/packages/sdk-logs/src/LogRecord.ts | 8 ++++---- .../packages/sdk-logs/src/export/ReadableLogRecord.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/experimental/packages/sdk-logs/src/LogRecord.ts b/experimental/packages/sdk-logs/src/LogRecord.ts index 7667b73550..39162597d1 100644 --- a/experimental/packages/sdk-logs/src/LogRecord.ts +++ b/experimental/packages/sdk-logs/src/LogRecord.ts @@ -26,7 +26,7 @@ import type { IResource } from '@opentelemetry/resources'; import type { ReadableLogRecord } from './export/ReadableLogRecord'; import type { LogRecordLimits } from './types'; -import { LogAttributes, LogAttributeValue } from '@opentelemetry/api-logs'; +import { LogAttributes, LogBody } from '@opentelemetry/api-logs'; import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState'; export class LogRecord implements ReadableLogRecord { @@ -38,7 +38,7 @@ export class LogRecord implements ReadableLogRecord { readonly attributes: logsAPI.LogAttributes = {}; private _severityText?: string; private _severityNumber?: logsAPI.SeverityNumber; - private _body?: LogAttributeValue; + private _body?: LogBody; private totalAttributesCount: number = 0; private _isReadonly: boolean = false; @@ -64,13 +64,13 @@ export class LogRecord implements ReadableLogRecord { return this._severityNumber; } - set body(body: LogAttributeValue | undefined) { + set body(body: LogBody | undefined) { if (this._isLogRecordReadonly()) { return; } this._body = body; } - get body(): LogAttributeValue | undefined { + get body(): LogBody | undefined { return this._body; } diff --git a/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts b/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts index c8fe8bc5f4..2af71de76b 100644 --- a/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts +++ b/experimental/packages/sdk-logs/src/export/ReadableLogRecord.ts @@ -18,7 +18,7 @@ import type { IResource } from '@opentelemetry/resources'; import type { HrTime, SpanContext } from '@opentelemetry/api'; import type { InstrumentationScope } from '@opentelemetry/core'; import type { - LogAttributeValue, + LogBody, LogAttributes, SeverityNumber, } from '@opentelemetry/api-logs'; @@ -29,7 +29,7 @@ export interface ReadableLogRecord { readonly spanContext?: SpanContext; readonly severityText?: string; readonly severityNumber?: SeverityNumber; - readonly body?: LogAttributeValue; + readonly body?: LogBody; readonly resource: IResource; readonly instrumentationScope: InstrumentationScope; readonly attributes: LogAttributes; From f215a17f7ff6e5198343c0d68d0a9e0a092eff97 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Fri, 29 Mar 2024 07:38:06 -0700 Subject: [PATCH 10/11] changed to non-breaking change in the core API --- api/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index 7fd5ea06e7..2d413fb75e 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -6,10 +6,10 @@ All notable changes to this project will be documented in this file. ### :boom: Breaking Change -* feat(api)!: add AnyValue and AnyValueMap types [#4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) - ### :rocket: (Enhancement) +* feat(api): add AnyValue and AnyValueMap types [#4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) + ### :bug: (Bug Fix) ### :books: (Refine Doc) From 712493efa6e7d22fc96cbaaf7db6cfae91e808a2 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Fri, 29 Mar 2024 16:55:08 -0700 Subject: [PATCH 11/11] moved AnyValue to Log API, updated changelog --- api/CHANGELOG.md | 2 -- api/src/common/Attributes.ts | 12 -------- api/src/index.ts | 7 +---- experimental/CHANGELOG.md | 4 ++- .../packages/api-events/src/types/Event.ts | 3 +- experimental/packages/api-logs/src/index.ts | 1 + .../packages/api-logs/src/types/AnyValue.ts | 29 +++++++++++++++++++ .../packages/api-logs/src/types/LogRecord.ts | 3 +- .../packages/sdk-logs/src/LogRecord.ts | 2 +- 9 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 experimental/packages/api-logs/src/types/AnyValue.ts diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index 2d413fb75e..f33bcbaddf 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -8,8 +8,6 @@ All notable changes to this project will be documented in this file. ### :rocket: (Enhancement) -* feat(api): add AnyValue and AnyValueMap types [#4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) - ### :bug: (Bug Fix) ### :books: (Refine Doc) diff --git a/api/src/common/Attributes.ts b/api/src/common/Attributes.ts index d02187302b..53a8166d84 100644 --- a/api/src/common/Attributes.ts +++ b/api/src/common/Attributes.ts @@ -35,15 +35,3 @@ export type AttributeValue = | Array | Array | Array; - -/** - * AnyValueMap is a map from string to AnyValue (attribute value or a nested map) - */ -export interface AnyValueMap { - [attributeKey: string]: AnyValue | undefined; -} - -/** - * AnyValue is a either an attribute value or a map of AnyValue(s) - */ -export type AnyValue = AttributeValue | AnyValueMap; diff --git a/api/src/index.ts b/api/src/index.ts index 108e56c6ee..c5dbe1685b 100644 --- a/api/src/index.ts +++ b/api/src/index.ts @@ -18,12 +18,7 @@ export { BaggageEntry, BaggageEntryMetadata, Baggage } from './baggage/types'; export { baggageEntryMetadataFromString } from './baggage/utils'; export { Exception } from './common/Exception'; export { HrTime, TimeInput } from './common/Time'; -export { - Attributes, - AttributeValue, - AnyValue, - AnyValueMap, -} from './common/Attributes'; +export { Attributes, AttributeValue } from './common/Attributes'; // Context APIs export { createContextKey, ROOT_CONTEXT } from './context/context'; diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index b8153427b9..eb535147df 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -21,12 +21,14 @@ All notable changes to experimental packages in this project will be documented * was used internally to keep track of the compression to use but was unintentionally exposed to the users. It allowed to read and write the value, writing, however, would have no effect. * feat(api-events)!: removed domain from the Events API [#4569](https://github.com/open-telemetry/opentelemetry-js/pull/4569) * fix(events-api)!: renamed EventEmitter to EventLogger in the Events API [#4569](https://github.com/open-telemetry/opentelemetry-js/pull/4568) -* feat(api-events)!: added data field to the Event interface [4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) +* feat(api-logs)!: changed LogRecord body data type to AnyValue [#4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) +and AnyValueMap types [#4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) ### :rocket: (Enhancement) * refactor(instr-http): use exported strings for semconv. [#4573](https://github.com/open-telemetry/opentelemetry-js/pull/4573/) @JamieDanielson * feat(sdk-node): add `HostDetector` as default resource detector +* feat(api-events): added data field to the Event interface [4575](https://github.com/open-telemetry/opentelemetry-js/pull/4575) ### :bug: (Bug Fix) diff --git a/experimental/packages/api-events/src/types/Event.ts b/experimental/packages/api-events/src/types/Event.ts index 00f68aea14..58456311cb 100644 --- a/experimental/packages/api-events/src/types/Event.ts +++ b/experimental/packages/api-events/src/types/Event.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AnyValue, Attributes } from '@opentelemetry/api'; +import { Attributes } from '@opentelemetry/api'; +import { AnyValue } from '@opentelemetry/api-logs'; export interface Event { /** diff --git a/experimental/packages/api-logs/src/index.ts b/experimental/packages/api-logs/src/index.ts index 34b4d8e20e..3ea2ae39c8 100644 --- a/experimental/packages/api-logs/src/index.ts +++ b/experimental/packages/api-logs/src/index.ts @@ -18,6 +18,7 @@ export * from './types/Logger'; export * from './types/LoggerProvider'; export * from './types/LogRecord'; export * from './types/LoggerOptions'; +export * from './types/AnyValue'; export * from './NoopLogger'; export * from './NoopLoggerProvider'; diff --git a/experimental/packages/api-logs/src/types/AnyValue.ts b/experimental/packages/api-logs/src/types/AnyValue.ts new file mode 100644 index 0000000000..7a97de7ed6 --- /dev/null +++ b/experimental/packages/api-logs/src/types/AnyValue.ts @@ -0,0 +1,29 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://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. + */ + +import { AttributeValue } from '@opentelemetry/api'; + +/** + * AnyValueMap is a map from string to AnyValue (attribute value or a nested map) + */ +export interface AnyValueMap { + [attributeKey: string]: AnyValue | undefined; +} + +/** + * AnyValue is a either an attribute value or a map of AnyValue(s) + */ +export type AnyValue = AttributeValue | AnyValueMap; diff --git a/experimental/packages/api-logs/src/types/LogRecord.ts b/experimental/packages/api-logs/src/types/LogRecord.ts index f4e8b20038..85d5e4ff4d 100644 --- a/experimental/packages/api-logs/src/types/LogRecord.ts +++ b/experimental/packages/api-logs/src/types/LogRecord.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AnyValue, AnyValueMap, Context, TimeInput } from '@opentelemetry/api'; +import { Context, TimeInput } from '@opentelemetry/api'; +import { AnyValue, AnyValueMap } from './AnyValue'; export type LogBody = AnyValue; export type LogAttributes = AnyValueMap; diff --git a/experimental/packages/sdk-logs/src/LogRecord.ts b/experimental/packages/sdk-logs/src/LogRecord.ts index 39162597d1..abc4f45285 100644 --- a/experimental/packages/sdk-logs/src/LogRecord.ts +++ b/experimental/packages/sdk-logs/src/LogRecord.ts @@ -157,7 +157,7 @@ export class LogRecord implements ReadableLogRecord { return this; } - public setBody(body: string) { + public setBody(body: LogBody) { this.body = body; return this; }