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

Introducing the instana.Collector #414

Merged
merged 2 commits into from
May 22, 2023
Merged

Introducing the instana.Collector #414

merged 2 commits into from
May 22, 2023

Conversation

willianpc
Copy link
Contributor

@willianpc willianpc commented Apr 4, 2023

This PR introduces Collector, a type that is composed by the same methods of Sensor, ot.Tracer and LeveledLogger, plus a few convenient methods. Collector is an implementation of the newly introduced TracerLogger interface.
It also deprecates InitSensor in favor of StartMetrics.

Why

The name "sensor" is misleading. What our tracer provides is a tracer collector.
Our tracer communicates to the Go Sensor, which is a plugin of the Instana Agent.

As we cannot delete public APIs, we then deprecate Sensor in favor of using the collector. This will happen in future PRs.

The sensor instance is still accessible via Collector.LegacySensor() and can be used for instrumentations. Exemple:

c := instana.InitCollector(&instana.Options{
	Service: "my-go-app",
})

handler := func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "Ok")
}

http.HandleFunc("/foo", instana.TracingHandlerFunc(c.LegacySensor(), "/foo", handler))

Features

  • The Collector is a concrete implementation of a new interface TracerLogger.
  • SensorLogger is a small interface representing all non-deprecated methods from Sensor
  • The TracerLogger interface embeds Tracer and LeveledLogger and the newly introduced SensorLogger.
  • It works as both Tracer and Logger, so their usage is less verbose:
    • Before: sensor.Tracer().StartSpan(...)
    • After: c.StartSpan...()
    • Before: s.Logger().Error()
    • After: c.Error()
  • Usage is simpler. There is no need to provide a tracer and then provide the options. The function InitCollector expects the options as an argument
  • A new Recorder option is available. It's usually used for testing, so customers shouldn't worry about setting it.
  • A new method instana.StartMetrics should be used in favor of instana.InitSensor for better naming.

@willianpc willianpc force-pushed the public-ref-sensor-api branch from 5774476 to 9129450 Compare April 26, 2023 09:28
@willianpc willianpc force-pushed the public-ref-sensor-api branch 3 times, most recently from 7cd02fd to 50f1ab1 Compare May 17, 2023 14:16
@willianpc willianpc changed the title initial version of controller proposal Introducing the instana.Collector May 17, 2023
@willianpc willianpc marked this pull request as ready for review May 17, 2023 14:38
@willianpc willianpc requested a review from a team May 17, 2023 14:38
Copy link
Contributor

@sanojsubran sanojsubran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me ! Great work @willianpc !

* TracerLogger interface now embeds instana.Tracer instead of ot.Tracer
* instana.Tracer interface added StartSpanWithOptions method to match tracerS
@willianpc willianpc force-pushed the public-ref-sensor-api branch from 7352a66 to 54137ee Compare May 19, 2023 13:03
@willianpc willianpc merged commit 44970f8 into main May 22, 2023
@willianpc willianpc deleted the public-ref-sensor-api branch May 22, 2023 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants