Skip to content

Commit

Permalink
Merge branch 'main' into update-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Mar 2, 2023
2 parents 4007625 + 494efff commit 79db51e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.

* fix(metrics): export `MetricsAPI` type [#3535](https://github.com/open-telemetry/opentelemetry-js/pull/3535)
* fix(api): rename `LoggerOptions` to `DiagLoggerOptions` [#3641](https://github.com/open-telemetry/opentelemetry-js/pull/3641)
* fix(api): export `DiagLoggerOptions` type [#3639](https://github.com/open-telemetry/opentelemetry-js/pull/3639)

## 1.4.0

Expand Down
1 change: 1 addition & 0 deletions api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export {
DiagLogger,
DiagLogLevel,
ComponentLoggerOptions,
DiagLoggerOptions,
} from './diag/types';
export type { DiagAPI } from './api/diag';

Expand Down
3 changes: 2 additions & 1 deletion experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ All notable changes to experimental packages in this project will be documented
* feat: use HTTP_ROUTE in span name [#3603](https://github.com/open-telemetry/opentelemetry-js/pull/3603) @Flarna
* feat: add HTTP_ROUTE attribute to http incoming metrics if present [#3581](https://github.com/open-telemetry/opentelemetry-js/pull/3581) @hermogenes
* feat(sdk-node): install diag logger with OTEL_LOG_LEVEL [#3627](https://github.com/open-telemetry/opentelemetry-js/pull/3627) @legendecas
* feat(otlp-exporter-base): add retries [#3207](https://github.com/open-telemetry/opentelemetry-js/pull/3207) @svetlanabrennan
* feat(sdk-node): override IdGenerator when using NodeSDK [#3645](https://github.com/open-telemetry/opentelemetry-js/pull/3645) @haddasbronfman

### :bug: (Bug Fix)

Expand Down Expand Up @@ -75,7 +77,6 @@ All notable changes to experimental packages in this project will be documented
* deps: remove unused proto-loader dependencies and update grpc-js and proto-loader versions [#3337](https://github.com/open-telemetry/opentelemetry-js/pull/3337) @seemk
* feat(metrics-exporters): configure temporality via environment variable [#3305](https://github.com/open-telemetry/opentelemetry-js/pull/3305) @pichlermarc
* feat(console-metric-exporter): add temporality configuration [#3387](https://github.com/open-telemetry/opentelemetry-js/pull/3387) @pichlermarc
* feat(otlp-exporter-base): add retries [#3207](https://github.com/open-telemetry/opentelemetry-js/pull/3207) @svetlanabrennan

### :bug: (Bug Fix)

Expand Down
3 changes: 3 additions & 0 deletions experimental/packages/opentelemetry-sdk-node/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ export class NodeSDK {
if (configuration.spanLimits) {
tracerProviderConfig.spanLimits = configuration.spanLimits;
}
if (configuration.idGenerator) {
tracerProviderConfig.idGenerator = configuration.idGenerator;
}

const spanProcessor =
configuration.spanProcessor ??
Expand Down
2 changes: 2 additions & 0 deletions experimental/packages/opentelemetry-sdk-node/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
SpanExporter,
SpanLimits,
SpanProcessor,
IdGenerator,
} from '@opentelemetry/sdk-trace-base';

export interface NodeSDKConfiguration {
Expand All @@ -41,4 +42,5 @@ export interface NodeSDKConfiguration {
spanProcessor: SpanProcessor;
traceExporter: SpanExporter;
spanLimits: SpanLimits;
idGenerator: IdGenerator;
}
28 changes: 28 additions & 0 deletions experimental/packages/opentelemetry-sdk-node/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
SimpleSpanProcessor,
BatchSpanProcessor,
NoopSpanProcessor,
IdGenerator,
} from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';
import * as semver from 'semver';
Expand Down Expand Up @@ -691,6 +692,33 @@ describe('Node SDK', () => {
});
});
});

describe('configure IdGenerator', async () => {
class CustomIdGenerator implements IdGenerator {
generateTraceId(): string {
return 'constant-test-trace-id';
}
generateSpanId(): string {
return 'constant-test-span-id';
}
}

it('should configure IdGenerator via config', async () => {
const idGenerator = new CustomIdGenerator();
const spanProcessor = new SimpleSpanProcessor(new ConsoleSpanExporter());
const sdk = new NodeSDK({
idGenerator,
spanProcessor,
});
sdk.start();

const span = trace.getTracer('test').startSpan('testName');
span.end();

assert.strictEqual(span.spanContext().spanId, 'constant-test-span-id');
assert.strictEqual(span.spanContext().traceId, 'constant-test-trace-id');
});
});
});

describe('setup exporter from env', () => {
Expand Down

0 comments on commit 79db51e

Please sign in to comment.