Skip to content

Commit

Permalink
moved AnyValue to Log API, updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkuba committed Mar 30, 2024
1 parent f215a17 commit 634c475
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 22 deletions.
12 changes: 0 additions & 12 deletions api/src/common/Attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,3 @@ export type AttributeValue =
| Array<null | undefined | string>
| Array<null | undefined | number>
| Array<null | undefined | boolean>;

/**
* 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;
7 changes: 1 addition & 6 deletions api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 3 additions & 1 deletion experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion experimental/packages/api-events/src/types/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
1 change: 1 addition & 0 deletions experimental/packages/api-logs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
29 changes: 29 additions & 0 deletions experimental/packages/api-logs/src/types/AnyValue.ts
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 2 additions & 1 deletion experimental/packages/api-logs/src/types/LogRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/sdk-logs/src/LogRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class LogRecord implements ReadableLogRecord {
return this;
}

public setBody(body: string) {
public setBody(body: LogBody) {
this.body = body;
return this;
}
Expand Down

0 comments on commit 634c475

Please sign in to comment.