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

New tracer #3836

Merged
merged 17 commits into from
Jun 25, 2020
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ Contents of "LICENSE":
--------------------------------------------------------------------
Dependency: github.com/elastic/beats/v7
Version: v7.0.0
Revision: 0dcb3dfebef7
Revision: 1498938e22f3
License type (autodetected): Apache-2.0

--------------------------------------------------------------------
Expand Down
70 changes: 37 additions & 33 deletions _meta/beat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,6 @@ apm-server:
# Url to expose expvar.
#url: "/debug/vars"

# Instrumentation support for the server's HTTP endpoints and event publisher.
#instrumentation:
# Set to true to enable instrumentation of the APM Server itself.
#enabled: false

# Environment in which the APM Server is running on (eg: staging, production, etc.)
#environment: ""

# Remote hosts to report instrumentation results to.
#hosts:
# - http://remote-apm-server:8200

# API Key for the remote APM Server(s).
# If api_key is set then secret_token will be ignored.
#api_key:

# Secret token for the remote APM Server(s).
#secret_token:

# Enable profiling of the server, recording profile samples as events.
#
# This feature is experimental.
#profiling:
#cpu:
# Set to true to enable CPU profiling.
#enabled: false
#interval: 60s
#duration: 10s
#heap:
# Set to true to enable heap profiling.
#enabled: false
#interval: 60s

# A pipeline is a definition of processors applied to documents when ingesting them to Elasticsearch.
# Using pipelines involves two steps:
# (1) registering a pipeline
Expand Down Expand Up @@ -983,6 +950,43 @@ output.elasticsearch:
# Kerberos realm.
#kerberos.realm: ELASTIC

#============================= Instrumentation =============================

# Instrumentation support for the server's HTTP endpoints and event publisher.
#instrumentation:

# Set to true to enable instrumentation of the APM Server itself.
#enabled: false

# Environment in which the APM Server is running on (eg: staging, production, etc.)
#environment: ""

# Hosts to report instrumentation results to.
# For reporting to itself, leave this field commented
#hosts:
# - http://remote-apm-server:8200

# API Key for the remote APM Server(s).
# If api_key is set then secret_token will be ignored.
#api_key:

# Secret token for the remote APM Server(s).
#secret_token:

# Enable profiling of the server, recording profile samples as events.
#
# This feature is experimental.
#profiling:
#cpu:
# Set to true to enable CPU profiling.
#enabled: false
#interval: 60s
#duration: 10s
#heap:
# Set to true to enable heap profiling.
#enabled: false
#interval: 60s

#================================= Paths ==================================

# The home path for the apm-server installation. This is the default base path
Expand Down
70 changes: 37 additions & 33 deletions apm-server.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,6 @@ apm-server:
# Url to expose expvar.
#url: "/debug/vars"

# Instrumentation support for the server's HTTP endpoints and event publisher.
#instrumentation:
# Set to true to enable instrumentation of the APM Server itself.
#enabled: false

# Environment in which the APM Server is running on (eg: staging, production, etc.)
#environment: ""

# Remote hosts to report instrumentation results to.
#hosts:
# - http://remote-apm-server:8200

# API Key for the remote APM Server(s).
# If api_key is set then secret_token will be ignored.
#api_key:

# Secret token for the remote APM Server(s).
#secret_token:

# Enable profiling of the server, recording profile samples as events.
#
# This feature is experimental.
#profiling:
#cpu:
# Set to true to enable CPU profiling.
#enabled: false
#interval: 60s
#duration: 10s
#heap:
# Set to true to enable heap profiling.
#enabled: false
#interval: 60s

# A pipeline is a definition of processors applied to documents when ingesting them to Elasticsearch.
# Using pipelines involves two steps:
# (1) registering a pipeline
Expand Down Expand Up @@ -983,6 +950,43 @@ output.elasticsearch:
# Kerberos realm.
#kerberos.realm: ELASTIC

#============================= Instrumentation =============================

# Instrumentation support for the server's HTTP endpoints and event publisher.
#instrumentation:

# Set to true to enable instrumentation of the APM Server itself.
#enabled: false

# Environment in which the APM Server is running on (eg: staging, production, etc.)
#environment: ""

# Hosts to report instrumentation results to.
# For reporting to itself, leave this field commented
#hosts:
# - http://remote-apm-server:8200

# API Key for the remote APM Server(s).
# If api_key is set then secret_token will be ignored.
#api_key:

# Secret token for the remote APM Server(s).
#secret_token:

# Enable profiling of the server, recording profile samples as events.
#
# This feature is experimental.
#profiling:
#cpu:
# Set to true to enable CPU profiling.
#enabled: false
#interval: 60s
#duration: 10s
#heap:
# Set to true to enable heap profiling.
#enabled: false
#interval: 60s

#================================= Paths ==================================

# The home path for the apm-server installation. This is the default base path
Expand Down
70 changes: 37 additions & 33 deletions apm-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,6 @@ apm-server:
# Url to expose expvar.
#url: "/debug/vars"

# Instrumentation support for the server's HTTP endpoints and event publisher.
#instrumentation:
# Set to true to enable instrumentation of the APM Server itself.
#enabled: false

# Environment in which the APM Server is running on (eg: staging, production, etc.)
#environment: ""

# Remote hosts to report instrumentation results to.
#hosts:
# - http://remote-apm-server:8200

# API Key for the remote APM Server(s).
# If api_key is set then secret_token will be ignored.
#api_key:

# Secret token for the remote APM Server(s).
#secret_token:

# Enable profiling of the server, recording profile samples as events.
#
# This feature is experimental.
#profiling:
#cpu:
# Set to true to enable CPU profiling.
#enabled: false
#interval: 60s
#duration: 10s
#heap:
# Set to true to enable heap profiling.
#enabled: false
#interval: 60s

# A pipeline is a definition of processors applied to documents when ingesting them to Elasticsearch.
# Using pipelines involves two steps:
# (1) registering a pipeline
Expand Down Expand Up @@ -983,6 +950,43 @@ output.elasticsearch:
# Kerberos realm.
#kerberos.realm: ELASTIC

#============================= Instrumentation =============================

# Instrumentation support for the server's HTTP endpoints and event publisher.
#instrumentation:

# Set to true to enable instrumentation of the APM Server itself.
#enabled: false

# Environment in which the APM Server is running on (eg: staging, production, etc.)
#environment: ""

# Hosts to report instrumentation results to.
# For reporting to itself, leave this field commented
#hosts:
# - http://remote-apm-server:8200

# API Key for the remote APM Server(s).
# If api_key is set then secret_token will be ignored.
#api_key:

# Secret token for the remote APM Server(s).
#secret_token:

# Enable profiling of the server, recording profile samples as events.
#
# This feature is experimental.
#profiling:
#cpu:
# Set to true to enable CPU profiling.
#enabled: false
#interval: 60s
#duration: 10s
#heap:
# Set to true to enable heap profiling.
#enabled: false
#interval: 60s

#================================= Paths ==================================

# The home path for the apm-server installation. This is the default base path
Expand Down
10 changes: 6 additions & 4 deletions beater/beater.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ type beater struct {
// Run runs the APM Server, blocking until the beater's Stop method is called,
// or a fatal error occurs.
func (bt *beater) Run(b *beat.Beat) error {
tracer, tracerServer, err := initTracer(b.Info, bt.config, bt.logger)
if err != nil {
return err

var tracerServer *tracerServer
var err error
if listener := b.Instrumentation.Listener(); listener != nil {
tracerServer = newTracerServer(bt.config, listener)
}
defer tracer.Close()

tracer := b.Instrumentation.Tracer()
runServer := runServer
if tracerServer != nil {
runServer = runServerWithTracerServer(runServer, tracerServer, tracer)
Expand Down
11 changes: 8 additions & 3 deletions beater/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (

"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/instrumentation"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/outputs"
pubs "github.com/elastic/beats/v7/libbeat/publisher"
Expand Down Expand Up @@ -514,11 +515,15 @@ func setupServer(t *testing.T, cfg *common.Config, beatConfig *beat.BeatConfig,
pub = dummyPipeline(cfg, info)
}

instrumentation, err := instrumentation.New(baseConfig, info.Beat, info.Version)
require.NoError(t, err)

// create a beat
apmBeat := &beat.Beat{
Publisher: pub,
Info: info,
Config: beatConfig,
Publisher: pub,
Info: info,
Config: beatConfig,
Instrumentation: instrumentation,
}
return setupBeater(t, apmBeat, baseConfig, beatConfig)
}
Expand Down
Loading