|
| 1 | +import { Tracer } from "@opentelemetry/api"; |
1 | 2 | import { |
2 | 3 | Instrumentation, |
3 | 4 | registerInstrumentations, |
4 | 5 | } from "@opentelemetry/instrumentation"; |
5 | | -import { Resource } from "@opentelemetry/resources"; |
6 | | -import { NodeTracerProvider, Tracer } from "@opentelemetry/sdk-trace-node"; |
| 6 | +import { resourceFromAttributes } from "@opentelemetry/resources"; |
| 7 | +import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node"; |
7 | 8 | import { AnthropicInstrumentation } from "@traceloop/instrumentation-anthropic"; |
8 | 9 | import { CohereInstrumentation } from "@traceloop/instrumentation-cohere"; |
9 | 10 | import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai"; |
@@ -147,12 +148,9 @@ class HumanloopTracerSingleton { |
147 | 148 | }; |
148 | 149 | }) { |
149 | 150 | this.tracerProvider = new NodeTracerProvider({ |
150 | | - resource: new Resource({ |
151 | | - attributes: { |
152 | | - // @ts-ignore |
153 | | - "service.name": "humanloop-typescript-sdk", |
154 | | - "service.version": SDK_VERSION, |
155 | | - }, |
| 151 | + resource: resourceFromAttributes({ |
| 152 | + "service.name": "humanloop-typescript-sdk", |
| 153 | + "service.version": SDK_VERSION, |
156 | 154 | }), |
157 | 155 | spanProcessors: [ |
158 | 156 | new HumanloopSpanProcessor( |
@@ -239,7 +237,8 @@ export class HumanloopClient extends BaseHumanloopClient { |
239 | 237 | return HumanloopTracerSingleton.getInstance({ |
240 | 238 | hlClientApiKey: this.options().apiKey!.toString(), |
241 | 239 | hlClientBaseUrl: |
242 | | - this.options().baseUrl!.toString() || HumanloopEnvironment.Default, |
| 240 | + this.options().baseUrl?.toString() || |
| 241 | + HumanloopEnvironment.Default.toString(), |
243 | 242 | instrumentProviders: this.instrumentProviders, |
244 | 243 | }).tracer; |
245 | 244 | } |
@@ -294,7 +293,8 @@ export class HumanloopClient extends BaseHumanloopClient { |
294 | 293 | HumanloopTracerSingleton.getInstance({ |
295 | 294 | hlClientApiKey: this.options().apiKey!.toString(), |
296 | 295 | hlClientBaseUrl: |
297 | | - this.options().baseUrl!.toString() || HumanloopEnvironment.Default, |
| 296 | + this.options().baseUrl?.toString() || |
| 297 | + HumanloopEnvironment.Default.toString(), |
298 | 298 | instrumentProviders: this.instrumentProviders, |
299 | 299 | }); |
300 | 300 | } |
|
0 commit comments