forked from DataDog/dd-trace-go
/
telemetry.go
50 lines (47 loc) · 2.35 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
// 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/lannguyen-c0x12c/dd-trace-go/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
}
configs := []telemetry.Configuration{}
telemetry.GlobalClient.ProductStart(telemetry.NamespaceProfilers,
append(configs, []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.traceEnabled},
{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},
}...))
}