Skip to content

Commit

Permalink
Fix instantiation of LoggerProvider to work in edge runtime
Browse files Browse the repository at this point in the history
the root cause is open-telemetry/opentelemetry-js#4473,
but it can be worked around by passing an empty `logRecordLimits` to the
LoggerProvider constructor.

fixes vercel#104
  • Loading branch information
sfishel18 committed Dec 3, 2024
1 parent faeb349 commit d134528
Show file tree
Hide file tree
Showing 2 changed files with 5,035 additions and 3,932 deletions.
14 changes: 8 additions & 6 deletions packages/otel/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class Sdk {
private meterProvider: MeterProvider | undefined;
private disableInstrumentations: (() => void) | undefined;

public constructor(private configuration: Configuration = {}) { }
public constructor(private configuration: Configuration = {}) {}

public start(): void {
const env = getEnv();
Expand Down Expand Up @@ -117,10 +117,9 @@ export class Sdk {
process.env.VERCEL_BRANCH_URL ||
process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL ||
undefined,
"vercel.deployment_id":
process.env.VERCEL_DEPLOYMENT_ID ||
undefined,
[SemanticResourceAttributes.SERVICE_VERSION]: process.env.VERCEL_DEPLOYMENT_ID,
"vercel.deployment_id": process.env.VERCEL_DEPLOYMENT_ID || undefined,
[SemanticResourceAttributes.SERVICE_VERSION]:
process.env.VERCEL_DEPLOYMENT_ID,

...configuration.attributes,
})
Expand Down Expand Up @@ -168,7 +167,10 @@ export class Sdk {
this.tracerProvider = tracerProvider;

if (configuration.logRecordProcessor) {
const loggerProvider = new LoggerProvider({ resource });
const loggerProvider = new LoggerProvider({
resource,
logRecordLimits: {},
});
this.loggerProvider = loggerProvider;
loggerProvider.addLogRecordProcessor(configuration.logRecordProcessor);
logs.setGlobalLoggerProvider(loggerProvider);
Expand Down
Loading

0 comments on commit d134528

Please sign in to comment.