generated from honeycombio/.github
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maint: remove resource merging in
honeycomb-resource
With `merge-resources`, we don't need to worry about consolidating additional resources w/in individual resource builders. Removes the `options` argument from the configuration builder Adds `getResourceAttributes` public method to `WebSDK`: I added this to for testing, but think i could be useful more generally to have a way of seeing the current resource attributes. When testing, realized if `resources` or `traceExporter` were set in the config options, they would overwrite our custom config. Swapped so the `resource` & `traceExporter`s bootstrapped in the `HoneycombWebSDK` constructor take precedence
- Loading branch information
Showing
5 changed files
with
24 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { HoneycombOptions } from './types'; | ||
import { VERSION } from './version'; | ||
|
||
export function configureHoneycombResource( | ||
options?: HoneycombOptions, | ||
): Resource { | ||
export function configureHoneycombResource(): Resource { | ||
return new Resource({ | ||
'honeycomb.distro.version': VERSION, | ||
'honeycomb.distro.runtime_version': 'browser', | ||
}).merge(options?.resource ? options.resource : null); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
import { HoneycombWebSDK } from '../src/honeycomb-otel-sdk'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { WebSDK } from '../src/base-otel-sdk'; | ||
import { VERSION } from '../src/version'; | ||
|
||
test('it should extend the OTel WebSDK', () => { | ||
const honeycomb = new HoneycombWebSDK(); | ||
expect(honeycomb).toBeInstanceOf(WebSDK); | ||
}); | ||
|
||
test('it should merge resources from the configuration', () => { | ||
const config = { | ||
resource: new Resource({ | ||
myTestAttr: 'my-test-attr', | ||
}), | ||
}; | ||
|
||
const honeycomb = new HoneycombWebSDK(config); | ||
|
||
const attributes = honeycomb.getResourceAttributes(); | ||
expect(attributes['honeycomb.distro.version']).toEqual(VERSION); | ||
expect(attributes['honeycomb.distro.runtime_version']).toEqual('browser'); | ||
expect(attributes.myTestAttr).toEqual('my-test-attr'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters