From 9ef3fc84f979e08ad2cf15d60d30936ebd611b0e Mon Sep 17 00:00:00 2001 From: Andrii Kushch Date: Wed, 29 Sep 2021 11:52:08 +0200 Subject: [PATCH] Upgrade Instana tracer and make process profiling configurable --- docs/content/observability/tracing/instana.md | 36 +++++++++++++++---- .../reference/static-configuration/cli-ref.md | 9 +++-- .../reference/static-configuration/env-ref.md | 9 +++-- go.mod | 2 +- go.sum | 9 +++-- pkg/tracing/instana/instana.go | 18 +++++----- 6 files changed, 56 insertions(+), 27 deletions(-) diff --git a/docs/content/observability/tracing/instana.md b/docs/content/observability/tracing/instana.md index e9eac66cf..c9447d807 100644 --- a/docs/content/observability/tracing/instana.md +++ b/docs/content/observability/tracing/instana.md @@ -1,6 +1,6 @@ # Instana -To enable the Instana: +To enable the Instana tracer: ```yaml tab="File (YAML)" tracing: @@ -18,9 +18,9 @@ tracing: #### `localAgentHost` -_Require, Default="127.0.0.1"_ +_Required, Default="127.0.0.1"_ -Local Agent Host instructs reporter to send spans to instana-agent at this address. +Local Agent Host instructs reporter to send spans to the Instana Agent at this address. ```yaml tab="File (YAML)" tracing: @@ -40,9 +40,9 @@ tracing: #### `localAgentPort` -_Require, Default=42699_ +_Required, Default=42699_ -Local Agent port instructs reporter to send spans to the instana-agent at this port. +Local Agent port instructs reporter to send spans to the Instana Agent listening on this port. ```yaml tab="File (YAML)" tracing: @@ -62,9 +62,9 @@ tracing: #### `logLevel` -_Require, Default="info"_ +_Required, Default="info"_ -Set Instana tracer log level. +Sets the Instana tracer log level. Valid values for logLevel field are: @@ -88,3 +88,25 @@ tracing: ```bash tab="CLI" --tracing.instana.logLevel=info ``` + +#### `enableAutoProfile` + +_Required, Default=false_ + +Enables [automatic profiling](https://www.instana.com/docs/ecosystem/go/#instana-autoprofile) for the Traefik process. + +```yaml tab="File (YAML)" +tracing: + instana: + enableAutoProfile: true +``` + +```toml tab="File (TOML)" +[tracing] + [tracing.instana] + enableAutoProfile = true +``` + +```bash tab="CLI" +--tracing.instana.enableAutoProfile=true +``` diff --git a/docs/content/reference/static-configuration/cli-ref.md b/docs/content/reference/static-configuration/cli-ref.md index f112a143c..87ba5ee58 100644 --- a/docs/content/reference/static-configuration/cli-ref.md +++ b/docs/content/reference/static-configuration/cli-ref.md @@ -927,14 +927,17 @@ Specifies the header name that will be used to store the trace ID. `--tracing.instana`: Settings for Instana. (Default: ```false```) +`--tracing.instana.enableautoprofile`: +Enables automatic profiling for the Traefik process. (Default: ```false```) + `--tracing.instana.localagenthost`: -Set instana-agent's host that the reporter will used. +Sets the Instana Agent host. `--tracing.instana.localagentport`: -Set instana-agent's port that the reporter will used. (Default: ```42699```) +Sets the Instana Agent port. (Default: ```42699```) `--tracing.instana.loglevel`: -Set instana-agent's log level. ('error','warn','info','debug') (Default: ```info```) +Sets the log level for the Instana tracer. ('error','warn','info','debug') (Default: ```info```) `--tracing.jaeger`: Settings for Jaeger. (Default: ```false```) diff --git a/docs/content/reference/static-configuration/env-ref.md b/docs/content/reference/static-configuration/env-ref.md index 2bd2af846..03733323b 100644 --- a/docs/content/reference/static-configuration/env-ref.md +++ b/docs/content/reference/static-configuration/env-ref.md @@ -927,14 +927,17 @@ Specifies the header name that will be used to store the trace ID. `TRAEFIK_TRACING_INSTANA`: Settings for Instana. (Default: ```false```) +`TRAEFIK_TRACING_INSTANA_ENABLEAUTOPROFILE`: +Enables automatic profiling for the Traefik process. (Default: ```false```) + `TRAEFIK_TRACING_INSTANA_LOCALAGENTHOST`: -Set instana-agent's host that the reporter will used. +Sets the Instana Agent host. `TRAEFIK_TRACING_INSTANA_LOCALAGENTPORT`: -Set instana-agent's port that the reporter will used. (Default: ```42699```) +Sets the Instana Agent port. (Default: ```42699```) `TRAEFIK_TRACING_INSTANA_LOGLEVEL`: -Set instana-agent's log level. ('error','warn','info','debug') (Default: ```info```) +Sets the log level for the Instana tracer. ('error','warn','info','debug') (Default: ```info```) `TRAEFIK_TRACING_JAEGER`: Settings for Jaeger. (Default: ```false```) diff --git a/go.mod b/go.mod index e0bef279b..914ec6d70 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-version v1.2.1 github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d - github.com/instana/go-sensor v1.5.1 + github.com/instana/go-sensor v1.31.1 github.com/klauspost/compress v1.13.0 github.com/libkermit/compose v0.0.0-20171122111507-c04e39c026ad github.com/libkermit/docker v0.0.0-20171122101128-e6674d32b807 diff --git a/go.sum b/go.sum index 4d008b4fb..c28a6365c 100644 --- a/go.sum +++ b/go.sum @@ -331,8 +331,6 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/felixge/httpsnoop v1.0.0 h1:gh8fMGz0rlOv/1WmRZm7OgncIOTsAj21iNJot48omJQ= -github.com/felixge/httpsnoop v1.0.0/go.mod h1:3+D9sFq0ahK/JeJPhCBUV1xlf4/eIYrUQaxulT0VzX8= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk= @@ -645,8 +643,10 @@ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d h1:/WZ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/infobloxopen/infoblox-go-client v1.1.1 h1:728A6LbLjptj/7kZjHyIxQnm768PWHfGFm0HH8FnbtU= github.com/infobloxopen/infoblox-go-client v1.1.1/go.mod h1:BXiw7S2b9qJoM8MS40vfgCNB2NLHGusk1DtO16BD9zI= -github.com/instana/go-sensor v1.5.1 h1:GLxYsYiDWD15RSXDHS70VvTVU/CbwUimWrK6/e4eBPQ= -github.com/instana/go-sensor v1.5.1/go.mod h1:5dEieTqu59XZr2/X53xF2Px4v83aSRRZa/47VbxAVa4= +github.com/instana/go-sensor v1.31.1 h1:Lzsv3Ju0mEtGgHP9nmuwxoWDYgMLJi+Loss5B01R1Bw= +github.com/instana/go-sensor v1.31.1/go.mod h1:Uh9j3eF2mBw/FLk2MxISmVDIj8mtJBFRj2S19M6CVyQ= +github.com/instana/testify v1.6.2-0.20200721153833-94b1851f4d65 h1:T25FL3WEzgmKB0m6XCJNZ65nw09/QIp3T1yXr487D+A= +github.com/instana/testify v1.6.2-0.20200721153833-94b1851f4d65/go.mod h1:nYhEREG/B7HUY7P+LKOrqy53TpIqmJ9JyUShcaEKtGw= github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= @@ -904,7 +904,6 @@ github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.m github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 h1:lM6RxxfUMrYL/f8bWEUqdXrANWtrL7Nndbm9iFN0DlU= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= -github.com/opentracing/basictracer-go v1.0.0 h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= diff --git a/pkg/tracing/instana/instana.go b/pkg/tracing/instana/instana.go index 104ce6b11..c7f538426 100644 --- a/pkg/tracing/instana/instana.go +++ b/pkg/tracing/instana/instana.go @@ -11,11 +11,12 @@ import ( // Name sets the name of this tracer. const Name = "instana" -// Config provides configuration settings for a instana tracer. +// Config provides configuration settings for an instana tracer. type Config struct { - LocalAgentHost string `description:"Set instana-agent's host that the reporter will used." json:"localAgentHost,omitempty" toml:"localAgentHost,omitempty" yaml:"localAgentHost,omitempty"` - LocalAgentPort int `description:"Set instana-agent's port that the reporter will used." json:"localAgentPort,omitempty" toml:"localAgentPort,omitempty" yaml:"localAgentPort,omitempty"` - LogLevel string `description:"Set instana-agent's log level. ('error','warn','info','debug')" json:"logLevel,omitempty" toml:"logLevel,omitempty" yaml:"logLevel,omitempty" export:"true"` + LocalAgentHost string `description:"Sets the Instana Agent host." json:"localAgentHost,omitempty" toml:"localAgentHost,omitempty" yaml:"localAgentHost,omitempty"` + LocalAgentPort int `description:"Sets the Instana Agent port." json:"localAgentPort,omitempty" toml:"localAgentPort,omitempty" yaml:"localAgentPort,omitempty"` + LogLevel string `description:"Sets the log level for the Instana tracer. ('error','warn','info','debug')" json:"logLevel,omitempty" toml:"logLevel,omitempty" yaml:"logLevel,omitempty" export:"true"` + EnableAutoProfile bool `description:"Enables automatic profiling for the Traefik process." json:"enableAutoProfile,omitempty" toml:"enableAutoProfile,omitempty" yaml:"enableAutoProfile,omitempty" export:"true"` } // SetDefaults sets the default values. @@ -40,10 +41,11 @@ func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error } tracer := instana.NewTracerWithOptions(&instana.Options{ - Service: serviceName, - LogLevel: logLevel, - AgentPort: c.LocalAgentPort, - AgentHost: c.LocalAgentHost, + Service: serviceName, + LogLevel: logLevel, + AgentPort: c.LocalAgentPort, + AgentHost: c.LocalAgentHost, + EnableAutoProfile: c.EnableAutoProfile, }) // Without this, child spans are getting the NOOP tracer