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.
feat: ✨ add semantic browser resource fields & honeycomb distro info (#…
…23) Swaps out the `browserDetection` export from `@opentelemetry/resources`, replaces it with the one provided by [`@opentelemetry/opentelemetry-browser-detector`](https://github.com/open-telemetry/opentelemetry-js/blob/57008533aba7ccd51ea80f38ff4f29404d47eb9c/experimental/packages/opentelemetry-browser-detector/src/BrowserDetector.ts)
- Loading branch information
Showing
8 changed files
with
134 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { HoneycombOptions } from './types'; | ||
import { VERSION } from './version'; | ||
|
||
export function configureHoneycombResource( | ||
options?: HoneycombOptions, | ||
): 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const VERSION = '0.0.1'; |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { configureHoneycombResource } from '../src/honeycomb-resource'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { VERSION } from '../src/version'; | ||
|
||
test('it should return a Resource', () => { | ||
const resource = configureHoneycombResource(); | ||
expect(resource).toBeInstanceOf(Resource); | ||
expect(resource.attributes['honeycomb.distro.version']).toEqual(VERSION); | ||
expect(resource.attributes['honeycomb.distro.runtime_version']).toEqual( | ||
'browser', | ||
); | ||
}); | ||
|
||
test('it should merge resource attributes provided from another resource', () => { | ||
const resource = configureHoneycombResource({ | ||
resource: new Resource({ | ||
myTestAttr: 'my-test-attr', | ||
}), | ||
}); | ||
expect(resource).toBeInstanceOf(Resource); | ||
expect(resource.attributes['honeycomb.distro.version']).toEqual(VERSION); | ||
expect(resource.attributes['honeycomb.distro.runtime_version']).toEqual( | ||
'browser', | ||
); | ||
expect(resource.attributes.myTestAttr).toEqual('my-test-attr'); | ||
}); |