Skip to content

Commit 409ab71

Browse files
committed
local testing, update collector processors
1 parent b78111a commit 409ab71

File tree

4 files changed

+39
-21
lines changed

4 files changed

+39
-21
lines changed

e2e/opentelemetry/go/collector.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ receivers:
1313
include_metadata: true
1414

1515
exporters:
16-
otlp:
17-
endpoint: https://otel.observability.app.launchdarkly.com:4317
16+
otlphttp:
17+
tls:
18+
insecure_skip_verify: true
19+
endpoint: http://host.docker.internal:4318
1820

1921
processors:
2022
attributes/environment:
@@ -27,28 +29,30 @@ processors:
2729
# value: <LD ENV ID>
2830
# action: upsert
2931

30-
# This filter removes all spans that do not have an HTTP route or any span events
31-
# remaining after the previous filter has been applied
32-
filter/launchdarkly-spans:
33-
error_mode: ignore
34-
traces:
35-
span:
36-
- 'not (attributes["http.route"] != nil or Len(events) > 0)'
37-
3832
batch:
3933

34+
tail_sampling/keep-errors-and-flags:
35+
policies:
36+
- name: keep_error_or_flag
37+
type: ottl_condition
38+
ottl_condition:
39+
error_mode: ignore
40+
spanevent:
41+
- 'name == "exception" or name == "feature_flag"'
42+
# or, if we want to only keep traces with a feature flag that is in a guarded rollout
43+
# - 'name == "exception" or (name == "feature_flag" and attributes["feature_flag.result.reason.inExperiment"] == true)'
44+
4045
service:
4146
pipelines:
4247
traces:
4348
receivers: [otlp]
44-
processors:
45-
[filter/launchdarkly-spans, attributes/environment, batch]
46-
exporters: [otlp]
49+
processors: [attributes/environment, batch]
50+
exporters: [otlphttp]
4751
metrics:
4852
receivers: [otlp]
4953
processors: [attributes/environment]
50-
exporters: [otlp]
54+
exporters: [otlphttp]
5155
logs:
5256
receivers: [otlp]
5357
processors: [attributes/environment]
54-
exporters: [otlp]
58+
exporters: [otlphttp]

e2e/opentelemetry/go/compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ services:
77
volumes:
88
- ./collector.yml:/etc/otelcol-contrib/config.yaml
99
ports:
10-
- '0.0.0.0:4317:4317'
11-
- '0.0.0.0:4318:4318'
10+
- '0.0.0.0:5317:4317'
11+
- '0.0.0.0:5318:4318'

e2e/opentelemetry/go/otel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func newTracerProvider(ctx context.Context, res *resource.Resource) (*trace.Trac
110110
// TODO: define the endpoints / https configuration as needed
111111

112112
traceExporter, err := otlptracehttp.New(ctx,
113-
otlptracehttp.WithEndpoint("localhost:4318"),
113+
otlptracehttp.WithEndpoint("localhost:5318"),
114114
otlptracehttp.WithInsecure(),
115115
)
116116
if err != nil {
@@ -128,7 +128,7 @@ func newTracerProvider(ctx context.Context, res *resource.Resource) (*trace.Trac
128128

129129
func newMeterProvider(ctx context.Context, res *resource.Resource) (*metric.MeterProvider, error) {
130130
metricExporter, err := otlpmetrichttp.New(ctx,
131-
otlpmetrichttp.WithEndpoint("localhost:4318"),
131+
otlpmetrichttp.WithEndpoint("localhost:5318"),
132132
otlpmetrichttp.WithInsecure(),
133133
)
134134
if err != nil {
@@ -146,7 +146,7 @@ func newMeterProvider(ctx context.Context, res *resource.Resource) (*metric.Mete
146146

147147
func newLoggerProvider(ctx context.Context, res *resource.Resource) (*log.LoggerProvider, error) {
148148
logExporter, err := otlploghttp.New(ctx,
149-
otlploghttp.WithEndpoint("localhost:4318"),
149+
otlploghttp.WithEndpoint("localhost:5318"),
150150
otlploghttp.WithInsecure(),
151151
)
152152
if err != nil {

e2e/opentelemetry/go/rolldice.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"errors"
45
"fmt"
56
"io"
67
"log"
@@ -12,6 +13,7 @@ import (
1213
"go.opentelemetry.io/otel"
1314
"go.opentelemetry.io/otel/attribute"
1415
"go.opentelemetry.io/otel/metric"
16+
"go.opentelemetry.io/otel/trace"
1517
)
1618

1719
const name = "go.opentelemetry.io/otel/example/dice"
@@ -47,6 +49,18 @@ func rolldice(w http.ResponseWriter, r *http.Request) {
4749
}
4850
logger.InfoContext(ctx, msg, "result", roll)
4951

52+
if rand.Intn(100) > 90 {
53+
span.RecordError(errors.New("example error"))
54+
}
55+
if rand.Intn(100) > 50 {
56+
span.AddEvent(
57+
"feature_flag",
58+
trace.WithAttributes(
59+
attribute.String("feature_flag.key", "foo"),
60+
attribute.Bool("feature_flag.result.reason.inExperiment", rand.Intn(100) > 90),
61+
))
62+
}
63+
5064
rollValueAttr := attribute.Int("roll.value", roll)
5165
span.SetAttributes(rollValueAttr)
5266
rollCnt.Add(ctx, 1, metric.WithAttributes(rollValueAttr))
@@ -55,4 +69,4 @@ func rolldice(w http.ResponseWriter, r *http.Request) {
5569
if _, err := io.WriteString(w, resp); err != nil {
5670
log.Printf("Write failed: %v\n", err)
5771
}
58-
}
72+
}

0 commit comments

Comments
 (0)