Skip to content

Commit 496bd33

Browse files
fix: Fallback to default trace endpoint for link exporter. (#444)
<!-- Thank you for contributing to the project! 💜 Please see our [OSS process document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#) to get an idea of how we operate. --> ## Which problem is this PR solving? - Closes #443 ## Short description of the changes Fall back to computed traces endpoint if not supplied. ## How to verify that this has the expected result Configure the sample app (without) providing an end point and run: ```shell npm run example:start:hello-world-web ``` You should see the SDK start successfully and links to traces in the console.
1 parent 4d72490 commit 496bd33

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

packages/honeycomb-opentelemetry-web/examples/hello-world-web/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const main = () => {
3030
dataAttributes: ['hello', 'barBiz'],
3131
},
3232
},
33+
localVisualizations: true,
3334
});
3435
sdk.start();
3536
const tracer = trace.getTracer('click-tracer');

packages/honeycomb-opentelemetry-web/src/console-trace-link-exporter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { HoneycombOptions } from './types';
44
import {
55
createHoneycombSDKLogMessage,
66
getTracesApiKey,
7+
getTracesEndpoint,
78
isClassic,
89
} from './util';
910
import {
@@ -24,7 +25,9 @@ export function configureConsoleTraceLinkExporter(
2425
options?: HoneycombOptions,
2526
): SpanExporter {
2627
const apiKey = getTracesApiKey(options);
27-
const { authRoot, uiRoot } = getUrlRoots(options?.endpoint);
28+
const { authRoot, uiRoot } = getUrlRoots(
29+
options?.tracesEndpoint || getTracesEndpoint(options),
30+
);
2831
return new ConsoleTraceLinkExporter(
2932
options?.serviceName,
3033
apiKey,

packages/honeycomb-opentelemetry-web/test/honeycomb-debug.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,34 @@ describe('when debug is set to true', () => {
6969
`@honeycombio/opentelemetry-web: Sample Rate configured for traces: '${testConfig.sampleRate}'`,
7070
);
7171
});
72+
it('should log the configured options to the console when endpoint is omitted', () => {
73+
const testConfig = {
74+
debug: true,
75+
apiKey: 'my-key',
76+
serviceName: 'my-service',
77+
sampleRate: 2,
78+
};
79+
new HoneycombWebSDK(testConfig);
80+
expect(consoleSpy).toHaveBeenNthCalledWith(
81+
3,
82+
'@honeycombio/opentelemetry-web: 🐝 Honeycomb Web SDK Debug Mode Enabled 🐝',
83+
);
84+
expect(consoleSpy).toHaveBeenNthCalledWith(
85+
4,
86+
`@honeycombio/opentelemetry-web: API Key configured for traces: '${testConfig.apiKey}'`,
87+
);
88+
expect(consoleSpy).toHaveBeenNthCalledWith(
89+
5,
90+
`@honeycombio/opentelemetry-web: Service Name configured for traces: '${testConfig.serviceName}'`,
91+
);
92+
expect(consoleSpy).toHaveBeenNthCalledWith(
93+
6,
94+
`@honeycombio/opentelemetry-web: Endpoint configured for traces: 'https://api.honeycomb.io/v1/traces'`,
95+
);
96+
expect(consoleSpy).toHaveBeenNthCalledWith(
97+
7,
98+
`@honeycombio/opentelemetry-web: Sample Rate configured for traces: '${testConfig.sampleRate}'`,
99+
);
100+
});
72101
});
73102
});

0 commit comments

Comments
 (0)