Skip to content

Commit

Permalink
Add WithTraceExporterOption
Browse files Browse the repository at this point in the history
Can e.g. be used to increase Exporting timeout.
  • Loading branch information
AndreasBergmeier6176 committed May 14, 2024
1 parent 8727607 commit fbdc8f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v0.0.60 Allow TraceExporterOption
- Enable passing options to `DiscoverServices` via `WithTraceExporterOption`

## v0.0.55 Allow setting of Extensions
- Introduces `ApplyCloudEventOptions` for applying Options to CloudEvents

Expand Down
16 changes: 15 additions & 1 deletion pkg/gcp/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type discoveryOption struct {
pod string
gkeAutoDiscoverMetaData bool
discoverPubSub bool
traceExporterOption texporter.Option
}

func WithKubernetes(clusterName, namespace, pod, containerName string) discoveryOption {
Expand Down Expand Up @@ -91,6 +92,12 @@ func WithGKEAutoDiscoverMetaData() discoveryOption {
}
}

func WithTraceExporterOption(to texporter.Option) discoveryOption {
return discoveryOption{
traceExporterOption: to,
}
}

// DiscoverServices builds clients for all Services that we use.
func DiscoverServices(project, serviceName string, tracerProviderOptions []sdktrace.TracerProviderOption, opts ...discoveryOption) (*Services, error) {
loggingClient, err := NewLoggingClient(project)
Expand All @@ -115,7 +122,14 @@ func DiscoverServices(project, serviceName string, tracerProviderOptions []sdktr
panic(err)
}

exporter, err := texporter.New(texporter.WithProjectID(project))
traceExporterOptions := []texporter.Option{texporter.WithProjectID(project)}
for _, opt := range opts {
if opt.traceExporterOption != nil {
traceExporterOptions = append(traceExporterOptions, opt.traceExporterOption)
}
}

exporter, err := texporter.New(traceExporterOptions...)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit fbdc8f3

Please sign in to comment.