Skip to content
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

Add extra resource attributes to config #127

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const createResource = (config: ResolvedTraceConfig): Resource => {
'service.namespace': config.service.namespace,
'service.version': config.service.version,
})
const resource = new Resource(workerResourceAttrs)
const resourceAttributes = Object.assign({}, workerResourceAttrs, config.extraResourceAttributes)
const resource = new Resource(resourceAttributes)
return resource.merge(serviceResource)
}

Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TextMapPropagator } from '@opentelemetry/api'
import { ResourceAttributes } from '@opentelemetry/resources'
import { ReadableSpan, Sampler, SpanExporter, SpanProcessor } from '@opentelemetry/sdk-trace-base'
import { OTLPExporterConfig } from './exporter.js'
import { FetchHandlerConfig, FetcherConfig } from './instrumentation/fetch.js'
Expand Down Expand Up @@ -31,6 +32,7 @@ export interface SamplingConfig<HS extends HeadSamplerConf = HeadSamplerConf> {

interface TraceConfigBase {
service: ServiceConfig
extraResourceAttributes?: ResourceAttributes
handlers?: HandlerConfig
fetch?: FetcherConfig
postProcessor?: PostProcessorFn
Expand Down