-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ✨ Add skipOptionsValidation
option and validate options
#77
Conversation
2c574b4
to
0b0d926
Compare
skipOptionsValidation
optionskipOptionsValidation
option and validate options
'🔨 WARN: Default deterministic sampler has been overridden. Honeycomb requires a resource attribute called SampleRate to properly show weighted values. Non-deterministic sampleRate could lead to missing spans in Honeycomb. See our docs for more details. https://docs.honeycomb.io/getting-data-in/opentelemetry/node-distro/#sampling-without-the-honeycomb-sdk'; | ||
|
||
export const validateOptionsWarnings = (options?: HoneycombOptions) => { | ||
if (options?.skipOptionsValidation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to do the logic of skipping validation inside the function instead at the top level in the SDK because it meant we could keep the SKIPPING_OPTIONS_VALIDATION_MSG
contained to this file
@@ -24,12 +24,14 @@ describe('when debug is set to true', () => { | |||
new HoneycombWebSDK({ | |||
debug: true, | |||
}); | |||
expect(consoleSpy.mock.calls[1][0]).toContain( | |||
'Honeycomb Web SDK Debug Mode Enabled', | |||
expect(consoleSpy).toHaveBeenNthCalledWith( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a lil refactor here to use Jest functions instead of array lookups because I found it really hard to pinpoint the right message quickly with the arrays 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I love this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all works great, though I do feel like there is a lot of intertwining between this and the debug file. Both things are intended to help warn a dev about incorrect setup. I left a few notes, though not sure about the broader question about how best to merge or separate this functionality from debug.
As an example, here is the output if debug mode is enabled, while setting an unnecessary dataset and missing a service name. Maybe some of that redundancy is fine though, especially with important missing items or if you want to skipValidation but still know in debug mode. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}; | ||
|
||
export const MISSING_API_KEY_ERROR = `❌ @honeycombio/opentelemetry-web: Missing API Key. Set \`apiKey\` in HoneycombOptions. Telemetry will not be exported.`; | ||
export const MISSING_SERVICE_NAME_ERROR = `❌ @honeycombio/opentelemetry-web: Missing Service Name. Set \`serviceName\` in HoneycombOptions. Defaulting to '${defaultOptions.serviceName}'`; | ||
export const createHoneycombSDKLogMessage = (message: string) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤩
Which problem is this PR solving?
Adds validation warnings for options.
Adds
skipOptionsValidation
option to config. This option is used when sending directly to a collector so warnings for not providing anapiKey
can be suppressed.Short description of the changes
apiKey
missingserviceName
missingdataset
is provided but theapiKey
is a E&S key and a `serviceName is provideddataset
is missing if a ClassicapiKey
is providedsampler
has been overriddenskipOptionsValidation
option that doesn't show any of these warnings if set totrue
, set tofalse
by defaultHow to verify that this has the expected result
apiKey
, you should see theapiKey
warning and so forthskipOptionsValidation
totrue
, you should see the skip options validation message and no other warnings