mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-10 09:50:58 +02:00
add resource attributes to provider
This commit is contained in:
parent
bbb7763a84
commit
d69386f56c
@ -3,6 +3,7 @@ module go.opentelemetry.io/otel/example/otel-collector
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/open-telemetry/opentelemetry-collector v0.3.0
|
||||
go.opentelemetry.io/otel v0.4.3
|
||||
go.opentelemetry.io/otel/exporters/otlp v0.4.3
|
||||
google.golang.org/grpc v1.29.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,8 +23,11 @@ import (
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"go.opentelemetry.io/otel/api/core"
|
||||
"go.opentelemetry.io/otel/exporters/otlp"
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
|
||||
"github.com/open-telemetry/opentelemetry-collector/translator/conventions"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -39,6 +42,9 @@ func main() {
|
||||
|
||||
tp, _ := sdktrace.NewProvider(
|
||||
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
|
||||
sdktrace.WithResourceAttributes(
|
||||
core.Key(conventions.AttributeServiceName).String("test-service"),
|
||||
),
|
||||
sdktrace.WithBatcher(exp, // add following two options to ensure flush
|
||||
sdktrace.WithScheduleDelayMillis(5),
|
||||
sdktrace.WithMaxExportBatchSize(2),
|
||||
@ -46,6 +52,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatalf("error creating trace provider: %v\n", err)
|
||||
}
|
||||
|
||||
tracer := tp.Tracer("test-tracer")
|
||||
|
||||
// Then use the OpenTelemetry tracing library, like we normally would.
|
||||
|
Loading…
Reference in New Issue
Block a user