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

Update trace apps #284

Open
wants to merge 7 commits 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
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,30 @@ pod "diag" deleted

### Trace stress-tester

`stress-tester` is a simple tool that generates a desired number of spans per minute and sends them using Jaeger format
`stress-tester` is a simple tool that generates a desired number of spans per minute and sends them using OpenTelemetry format

```
kubectl run stress-tester \
-it --rm \
--restart=Never -n sumologic \
--image sumologic/kubernetes-tools \
--serviceaccount='collection-sumologic' \
--env JAEGER_AGENT_HOST=collection-sumologic-otelcol.sumologic \
--env JAEGER_AGENT_PORT=6831 \
--env COLLECTOR_HOSTNAME=collection-sumologic-otelagent.sumologic \
--env EXPORTER=http \
--env TOTAL_SPANS=1000000 \
--env SPANS_PER_MIN=6000 \
-- stress-tester
```

#### Configuration

You can set Jaeger Go client env variables (such as `JAEGER_AGENT_HOST` or `JAEGER_COLLECTOR`) and stress-tester specific ones:
You can set provide configuration to stress-tester by environment variables:

- `TOTAL_SPANS` (default=10000000) - total number of spans to generate
- `SPANS_PER_MIN` (required) - rate of spans per minute (the tester will adjust the delay between iterations to reach such rate)
- `SPANS_PER_TRACE` (default=`100`) - number of spans generated for a single trace
- `COLLECTOR_HOSTNAME` (default=`collection-sumologic-otelagent.sumologic`) - OpenTelemetry collector endpoint
- `EXPORTER` (default=`http`) - select which exporter is used, OTLP `http` or `grpc`

### Customer Trace Tester

Expand All @@ -99,7 +102,7 @@ Traces can be easily found with the `service=customer-trace-test-service` filter
--restart=Never -n sumologic \
--image sumologic/kubernetes-tools \
--serviceaccount='collection-sumologic' \
--env COLLECTOR_HOSTNAME=collection-sumologic-otelcol.sumologic \
--env COLLECTOR_HOSTNAME=collection-sumologic-otelagent.sumologic \
--env TOTAL_TRACES=1 \
--env SPANS_PER_TRACE=10 \
-- customer-trace-tester
Expand All @@ -109,37 +112,38 @@ Traces can be easily found with the `service=customer-trace-test-service` filter

You can configure this tool by setting the following env variables:

- `COLLECTOR_HOSTNAME` (default=`collection-sumologic-otelcol.sumologic`) - the hostname/service of OpenTelemetry Collector
- `COLLECTOR_HOSTNAME` (default=`collection-sumologic-otelagent.sumologic`) - the hostname/service of OpenTelemetry Collector
- `TOTAL_TRACES` (default=`1`) - total number of traces to generate
- `SPANS_PER_TRACE` (default=`10`) - number of spans per trace
- `OTLP_HTTP_PORT` (default=`4318`) - port number for OTLP HTTP exporter

#### Example output

```
./customer-trace-tester

2021/07/09 00:32:48 OTLP gRPC Exporter endpoint: collection-sumologic-otelcol.sumologic:4317
2021/07/09 00:32:48 OTLP HTTP Exporter endpoint: collection-sumologic-otelcol.sumologic:4317
2021/07/09 00:32:48 Zipkin Exporter url: http://collection-sumologic-otelcol.sumologic:9411/api/v2/spans
2021/07/09 00:32:48 Jaeger Thrift HTTP Exporter url: http://collection-sumologic-otelcol.sumologic:14268/api/traces
2021/07/09 00:32:48 OTLP gRPC Exporter endpoint: collection-sumologic-otelagent.sumologic:4317
2021/07/09 00:32:48 OTLP HTTP Exporter endpoint: collection-sumologic-otelagent.sumologic:4317
2021/07/09 00:32:48 Zipkin Exporter url: http://collection-sumologic-otelagent.sumologic:9411/api/v2/spans
2021/07/09 00:32:48 Jaeger Thrift HTTP Exporter url: http://collection-sumologic-otelagent.sumologic:14268/api/traces
2021/07/09 00:32:48 *******************************
2021/07/09 00:32:48 Sending traces thru otlpHttp exporter
2021/07/09 00:32:48 COLLECTOR_HOSTNAME = collection-sumologic-otelcol.sumologic:4317
2021/07/09 00:32:48 COLLECTOR_HOSTNAME = collection-sumologic-otelagent.sumologic
2021/07/09 00:32:48 TOTAL_TRACES = 1
2021/07/09 00:32:48 SPANS_PER_TRACE = 10
2021/07/09 00:32:54 *******************************
2021/07/09 00:32:54 Sending traces thru otlpGrpc exporter
2021/07/09 00:32:54 COLLECTOR_HOSTNAME = collection-sumologic-otelcol.sumologic:4317
2021/07/09 00:32:54 COLLECTOR_HOSTNAME = collection-sumologic-otelagent.sumologic
2021/07/09 00:32:54 TOTAL_TRACES = 1
2021/07/09 00:32:54 SPANS_PER_TRACE = 10
2021/07/09 00:32:59 *******************************
2021/07/09 00:32:59 Sending traces thru zipkin exporter
2021/07/09 00:32:59 COLLECTOR_HOSTNAME = collection-sumologic-otelcol.sumologic:4317
2021/07/09 00:32:59 COLLECTOR_HOSTNAME = collection-sumologic-otelagent.sumologic
2021/07/09 00:32:59 TOTAL_TRACES = 1
2021/07/09 00:32:59 SPANS_PER_TRACE = 10
2021/07/09 00:33:04 *******************************
2021/07/09 00:33:04 Sending traces thru jaegerThriftHttp exporter
2021/07/09 00:33:04 COLLECTOR_HOSTNAME = collection-sumologic-otelcol.sumologic:4317
2021/07/09 00:33:04 COLLECTOR_HOSTNAME = collection-sumologic-otelagent.sumologic
2021/07/09 00:33:04 TOTAL_TRACES = 1
2021/07/09 00:33:04 SPANS_PER_TRACE = 10
2021/07/09 00:33:10 *******************************
Expand Down
24 changes: 16 additions & 8 deletions src/go/cmd/customer-trace-tester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type traceTestConfig struct {
spansPerTrace int
// How many Traces should be generated
totalTraces int
// OTLP HTTP exporter port number
otlpHttpPort int
}

const (
Expand All @@ -54,19 +56,22 @@ const (
EnvSpansPerTrace = "SPANS_PER_TRACE"
// EnvTotalTraces Number of traces generated per exporter
EnvTotalTraces = "TOTAL_TRACES"
// EnvOTLPHttpPort OTLP HTTP exporter port number
EnvOTLPHttpPort = "OTLP_HTTP_PORT"
)

func (cfg *traceTestConfig) printConfig() {
log.Printf("%s = %s\n", EnvCollectorHostName, cfg.collectorHostName)
log.Printf("%s = %d\n", EnvTotalTraces, cfg.totalTraces)
log.Printf("%s = %d\n", EnvSpansPerTrace, cfg.spansPerTrace)
log.Printf("%s = %d\n", EnvOTLPHttpPort, cfg.spansPerTrace)
}

func createTraceTestConfig() traceTestConfig {

collectorHostName := os.Getenv(EnvCollectorHostName)
if collectorHostName == "" {
collectorHostName = "collection-sumologic-otelcol.sumologic"
collectorHostName = "collection-sumologic-otelagent.sumologic"
}

spansPerTrace, err := strconv.Atoi(os.Getenv(EnvSpansPerTrace))
Expand All @@ -79,10 +84,16 @@ func createTraceTestConfig() traceTestConfig {
totalTraces = 1
}

otlpHttpPort, err := strconv.Atoi(os.Getenv(EnvOTLPHttpPort))
if err != nil {
otlpHttpPort = 4318
}

return traceTestConfig{
collectorHostName: collectorHostName,
spansPerTrace: spansPerTrace,
totalTraces: totalTraces,
otlpHttpPort: otlpHttpPort,
}
}

Expand All @@ -102,8 +113,8 @@ func configureOtlpGrpcExporter(ctx context.Context, collectorHostName string) sd
return bsp
}

func configureOtlpHTTPExporter(ctx context.Context, collectorHostName string) sdktrace.SpanProcessor {
endpoint := fmt.Sprintf("%s:55681", collectorHostName)
func configureOtlpHTTPExporter(ctx context.Context, collectorHostName string, otlpHttpPort int) sdktrace.SpanProcessor {
endpoint := fmt.Sprintf("%s:%d", collectorHostName, otlpHttpPort)
log.Printf("OTLP HTTP Exporter endpoint: %s\n", endpoint)

opts := []otlptracehttp.Option{
Expand All @@ -123,10 +134,7 @@ func configureZipkinExporter(collectorHostName string) sdktrace.SpanProcessor {
url := fmt.Sprintf("http://%s:9411/api/v2/spans", collectorHostName)
log.Printf("Zipkin Exporter url: %s\n", url)

traceExporter, err := zipkin.New(
url,
zipkin.WithSDKOptions(sdktrace.WithSampler(sdktrace.AlwaysSample())),
)
traceExporter, err := zipkin.New(url)
handleErr("Failed to create Zipkin trace exporter", err)
bsp := sdktrace.NewBatchSpanProcessor(traceExporter)

Expand Down Expand Up @@ -245,7 +253,7 @@ func main() {
testCfg := createTraceTestConfig()

otlpGrpcExporter := configureOtlpGrpcExporter(context.Background(), testCfg.collectorHostName)
otlpHTTPExporter := configureOtlpHTTPExporter(context.Background(), testCfg.collectorHostName)
otlpHTTPExporter := configureOtlpHTTPExporter(context.Background(), testCfg.collectorHostName, testCfg.otlpHttpPort)
zipkinExporter := configureZipkinExporter(testCfg.collectorHostName)
jaegerThriftHTTPExporter := configureJaegerThriftHTTPExporter(testCfg.collectorHostName)
spanProcessors := map[string]sdktrace.SpanProcessor{
Expand Down
Loading