Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0ac450e
WIP sync and async resource merge
dyladan Jan 16, 2025
49ef5ed
Fix isPromiseLike
dyladan Jan 16, 2025
29ccd0f
Fix tests - TODO: attribute fallback order
dyladan Jan 17, 2025
767947c
Fix resource usages for 2.x
dyladan Jan 21, 2025
9aba287
Fix remaining tests
dyladan Jan 22, 2025
9f231aa
Unskip tests
dyladan Jan 22, 2025
13f2064
Remove deep export
dyladan Jan 22, 2025
2fa42c8
Review comments
dyladan Jan 22, 2025
ff5af1a
Remove noop detector export
dyladan Jan 22, 2025
8e513e4
Merge remote-tracking branch 'origin/main' into resource-async-sync
dyladan Jan 22, 2025
8236217
Lint and cleanup
dyladan Jan 22, 2025
36d6b9c
Changelog
dyladan Jan 22, 2025
c1f6d24
Changelog
dyladan Jan 22, 2025
1de27ba
Use shared empty resource
dyladan Jan 23, 2025
20d297d
Make asyncAttributesPending readonly
dyladan Jan 23, 2025
6d1f3a0
Add explicit return type to resource merge
dyladan Jan 23, 2025
f13ba2c
Fix types and lint
dyladan Jan 23, 2025
15f54f0
Create new resource from list
dyladan Jan 23, 2025
e6dce6b
Explict return types
dyladan Jan 27, 2025
7a93c59
revert package lock changes
dyladan Jan 27, 2025
0467bc8
Merge remote-tracking branch 'origin/main' into resource-async-sync
dyladan Jan 27, 2025
fd4bab8
Revert package lock changes
dyladan Jan 27, 2025
9c74732
Use strict equal
dyladan Jan 27, 2025
9e55991
Fix test compilation
dyladan Jan 28, 2025
eba4a63
Do not await non-promise
dyladan Jan 29, 2025
cd8a8f1
Review comment
dyladan Jan 29, 2025
dde176a
Add comment about merge order
dyladan Jan 31, 2025
ee3e732
Merge remote-tracking branch 'origin/main' into resource-async-sync
dyladan Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/main' into resource-async-sync
  • Loading branch information
dyladan committed Jan 22, 2025
commit 8e513e45c94346dcc43dd1d659f2726541e7b86f
5 changes: 1 addition & 4 deletions experimental/packages/opentelemetry-sdk-node/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export class NodeSDK {

private _resource: IResource;
private _resourceDetectors: Array<ResourceDetector>;
private _mergeResourceWithDefaults: boolean;

private _autoDetectResources: boolean;

Expand Down Expand Up @@ -244,9 +243,7 @@ export class NodeSDK {

this._configuration = configuration;

this._resource = configuration.resource ?? new Resource({ attributes: {}});
this._mergeResourceWithDefaults =
configuration.mergeResourceWithDefaults ?? true;
this._resource = configuration.resource ?? Resource.default();
this._autoDetectResources = configuration.autoDetectResources ?? true;
if (!this._autoDetectResources) {
this._resourceDetectors = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export interface NodeSDKConfiguration {
instrumentations: (Instrumentation | Instrumentation[])[];
resource: IResource;
resourceDetectors: Array<ResourceDetector>;
mergeResourceWithDefaults?: boolean;
sampler: Sampler;
serviceName?: string;
/** @deprecated use spanProcessors instead*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ describe('Node SDK', () => {
const resource = sdk['_resource'];
await resource.waitForAsyncAttributes?.();

assert.deepStrictEqual(resource, Resource.EMPTY);
assert.deepStrictEqual(resource, Resource.default());
await sdk.shutdown();
});
});
Expand Down
14 changes: 1 addition & 13 deletions experimental/packages/sdk-logs/src/LoggerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { diag } from '@opentelemetry/api';
import type * as logsAPI from '@opentelemetry/api-logs';
import { NOOP_LOGGER } from '@opentelemetry/api-logs';
import { IResource, Resource } from '@opentelemetry/resources';
import { Resource } from '@opentelemetry/resources';
import { BindOnceFuture, merge } from '@opentelemetry/core';

import type { LoggerProviderConfig } from './types';
Expand All @@ -28,18 +28,6 @@ import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState'

export const DEFAULT_LOGGER_NAME = 'unknown';

function prepareResource(
mergeWithDefaults: boolean,
providedResource: IResource | undefined
) {
const resource = providedResource ?? Resource.EMPTY;

if (mergeWithDefaults) {
return Resource.default().merge(resource);
}
return resource;
}

export class LoggerProvider implements logsAPI.LoggerProvider {
private _shutdownOnce: BindOnceFuture<void>;
private readonly _sharedState: LoggerProviderSharedState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,38 +63,15 @@ describe('LoggerProvider', () => {
assert.deepStrictEqual(resource, Resource.default());
});

it('should fallback to default resource attrs', () => {
const passedInResource = new Resource({ attributes: { foo: 'bar' }});
const provider = new LoggerProvider({ resource: passedInResource });
const { resource } = provider['_sharedState'];
assert.deepStrictEqual(
resource,
Resource.default().merge(passedInResource)
);
});

it('should not merge with default resource attrs when flag is set to false', function () {
const passedInResource = new Resource({ attributes: { foo: 'bar' }});
it('should not have default resource if passed', function () {
const passedInResource = new Resource({ attributes: { foo: 'bar' } });
const provider = new LoggerProvider({
resource: passedInResource,
});
const { resource } = provider['_sharedState'];
assert.deepStrictEqual(resource, passedInResource);
});

it('should merge with default resource attrs when flag is set to true', function () {
const passedInResource = new Resource({ attributes: { foo: 'bar' }});
const provider = new LoggerProvider({
resource: passedInResource,
mergeResourceWithDefaults: true,
});
const { resource } = provider['_sharedState'];
assert.deepStrictEqual(
resource,
Resource.default().merge(passedInResource)
);
});

it('should have default forceFlushTimeoutMillis if not pass', () => {
const provider = new LoggerProvider();
const sharedState = provider['_sharedState'];
Expand Down
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.