-
Notifications
You must be signed in to change notification settings - Fork 419
/
telemetry.go
59 lines (56 loc) · 2.57 KB
/
telemetry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016 Datadog, Inc.
package profiler
import (
"github.com/DataDog/dd-trace-go/v2/internal/telemetry"
)
// startTelemetry starts the global instrumentation telemetry client with profiler data
// unless instrumentation telemetry is disabled via the DD_INSTRUMENTATION_TELEMETRY_ENABLED
// env var.
// If the telemetry client has already been started by the tracer, then
// app-product-change event is queued to signal the profiler is enabled, and an
// app-client-configuration-change event is also queued with profiler config data.
func startTelemetry(c *config) {
if telemetry.Disabled() {
// Do not do extra work populating config data if instrumentation telemetry is disabled.
return
}
profileEnabled := func(t ProfileType) bool {
_, ok := c.types[t]
return ok
}
telemetry.GlobalClient.ApplyOps(
telemetry.WithService(c.service),
telemetry.WithEnv(c.env),
telemetry.WithHTTPClient(c.httpClient),
telemetry.WithURL(c.agentless, c.agentURL),
)
telemetry.GlobalClient.ProductChange(
telemetry.NamespaceProfilers,
true,
[]telemetry.Configuration{
{Name: "delta_profiles", Value: c.deltaProfiles},
{Name: "agentless", Value: c.agentless},
{Name: "profile_period", Value: c.period.String()},
{Name: "cpu_duration", Value: c.cpuDuration.String()},
{Name: "cpu_profile_rate", Value: c.cpuProfileRate},
{Name: "block_profile_rate", Value: c.blockRate},
{Name: "mutex_profile_fraction", Value: c.mutexFraction},
{Name: "max_goroutines_wait", Value: c.maxGoroutinesWait},
{Name: "cpu_profile_enabled", Value: profileEnabled(CPUProfile)},
{Name: "heap_profile_enabled", Value: profileEnabled(HeapProfile)},
{Name: "block_profile_enabled", Value: profileEnabled(BlockProfile)},
{Name: "mutex_profile_enabled", Value: profileEnabled(MutexProfile)},
{Name: "goroutine_profile_enabled", Value: profileEnabled(GoroutineProfile)},
{Name: "goroutine_wait_profile_enabled", Value: profileEnabled(expGoroutineWaitProfile)},
{Name: "upload_timeout", Value: c.uploadTimeout.String()},
{Name: "execution_trace_enabled", Value: c.traceConfig.Enabled},
{Name: "execution_trace_period", Value: c.traceConfig.Period.String()},
{Name: "execution_trace_size_limit", Value: c.traceConfig.Limit},
{Name: "endpoint_count_enabled", Value: c.endpointCountEnabled},
{Name: "num_custom_profiler_label_keys", Value: len(c.customProfilerLabels)},
},
)
}