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

βœ¨πŸ”§ Setup Open Telemetry Metrics and Traces #237

Merged
merged 2 commits into from
May 5, 2024

Conversation

gernest
Copy link
Collaborator

@gernest gernest commented May 5, 2024

Closes #221

We use go.opentelemetry.io/contrib/exporters/autoexport for standard loading exporter configurations via env variables.

This commit, initialize metrics meter and tracer. There is no need to pass the providers in *telemetry.Telemetry because they are globally available via otel package.

Only setup is implemented here to simplify review. Instrumentation will be done in followup patches.

gernest added 2 commits May 5, 2024 15:29
Closes EinStack#221

We use `go.opentelemetry.io/contrib/exporters/autoexport`` for standard loading
exporter configurations via env variables.

This commit, initialize metrics meter and tracer. There is no need to pass
the providers in `*telemetry.Telemetry` because they are globally available
via `otel` package.

Only setup is implemented here to simplify review. Instrumentation will be
done in followup patches.
@gernest gernest requested review from roma-glushko and mkrueger12 May 5, 2024 12:47
@roma-glushko roma-glushko changed the title Setup Open Telemetry Metrics and Traces βœ¨πŸ”§ Setup Open Telemetry Metrics and Traces May 5, 2024
@roma-glushko roma-glushko added type:enhancement New feature or request area:telemetry Logging, metrics, traces labels May 5, 2024

var Resource = resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceName("glide"),
Copy link
Member

Choose a reason for hiding this comment

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

We also should pass the service version and service.instance.id. Plus, it's nice to be able to override those values like OTEL collector allows (https://github.com/open-telemetry/opentelemetry-collector/blob/4d73b4f1bfee7e710521d29b094c2c2ce473b2c7/service/internal/resource/config.go#L16-L15)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure , that is beyond the scope of the PR. This is strictly for setting up providers. Your comment falls under instrumentation.

Copy link
Member

Choose a reason for hiding this comment

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

That's fine to leave it out in this PR but #221 was including that thing explicitly. Dont' want us to miss that requirement along the way if we close the task

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My bad! I thought about discussing it there but got sidetracked. @roma-glushko is there a way to squeeze this in existing instrumentation tasks ?

Copy link
Member

Choose a reason for hiding this comment

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

Sure thing, no worries! I will move it into a sep task

Copy link
Member

Choose a reason for hiding this comment

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

#241 - the ticket βœ…

sdktrace.WithBatcher(spanExporter),
)
otel.SetTracerProvider(tp)
otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}))
Copy link
Member

Choose a reason for hiding this comment

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

Does this include the B3 propagation protocol?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nope, just standard https://www.w3.org/TR/trace-context/ is B3 a hard requirement ?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we want to support both OTEL context propagation and B3. Please install the B3 propagator, too.


type Config struct {
LogConfig *LogConfig `yaml:"logging" validate:"required"`
// TODO: add OTEL config
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts out loud.

This auto instrumentation follows a bit different idea than Glide's config.
I would like to see all configuration done via Glide config, so there is one single place to take a look.
Autoinstrumentation creates another place to look at which environment variables which means that now we would have two places to consider in order to fully understand a gateway setup.

Not sure if that's going to be confusing for end users or not.

Functionally though, autoinstrumentation seems to have everything we need:

  • ability to disable/enable trace exporting
  • ability to disable enable metric exporting (independently from tracing and vice versa)

https://github.com/EinStack/charts/blob/main/charts/glide/templates/_pod.tpl#L32-L50 - the helm chart is ready to accept additional env vars, too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Personally I would rather stick with the standards. Users configuring telemetry should only care about their otel setup, we can leverage otel documentation meaning we don't need to upgrade telemetry docs whenever we upgrade our otel packages.

However, one thing I agree with you is the options which are essential for instrumentation. Things like instance id's you mentioned. Those indeed needs to be set in configuration.

Copy link
Member

Choose a reason for hiding this comment

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

Users configuring telemetry should only care about their otel setup, we can leverage otel documentation meaning we don't need to upgrade telemetry docs whenever we upgrade our otel packages.

I guess it's saving us a bit of typing by providing those registries and implicit configurations via env vars. That's the biggest advantages I see. Also, some configs may appear in the upcoming versions of OTEL SDK that are available right away as we upgrade SDK (without a need to propagate them manually).

@gernest
Copy link
Collaborator Author

gernest commented May 5, 2024

@roma-glushko I think assigning is for issues not PR. What I want is a review. And I would really appreciate if my PR's descriptions/titles are not modified without notice.

Emojis adds cognitive load.

@roma-glushko roma-glushko merged commit 602f53e into EinStack:develop May 5, 2024
6 checks passed
@roma-glushko
Copy link
Member

What I want is a review. And I would really appreciate if my PR's descriptions/titles are not modified without notice.Emojis adds cognitive load.

@gernest did not really get what's the matter with this one?
I have to format titles, because they will land in changelog in a semi-automated way as well as git history.

I think assigning is for issues not PR.

But PRs have the field, right? 😌

@gernest
Copy link
Collaborator Author

gernest commented May 5, 2024

@gernest did not really get what's the matter with this one?
I have to format titles, because they will land in changelog in a semi-automated way as well as git history.

@roma-glushko sorry man, my lizard brain had completely forgotten about changelogs, forget what I said.

But PRs have the field, right? 😌

Yes, but for PR it is used when someone else takes over a PR. If I am the author, it does not make sense to assign me my own work.

roma-glushko added a commit that referenced this pull request Jun 24, 2024
The first major update with breaking changes to the language chat schemas 
and begging of work on instrumenting the gateway with OpenTelemetry.

### Added

- πŸ”§ Use github.com/EinStack/glide as module name to support go install cmd (@gernest)
- βœ¨πŸ”§ Setup Open Telemetry Metrics and Traces (#237) (@gernest)
-  πŸ”§ #221 Add B3 trace propagator (#242) (@gernest)
- πŸ”§ #241 Support overriding OTEL resource attributes (#243) (@gernest)
- πŸ”§ #248 Disable span and metrics by default (#254) (@gernest)
- πŸ”§ #220 Instrument API server with observability signals (#255) (@gernest)
- πŸ”§ #164 Make client connection pool configurable across all providers (#251) (@daesu)
- πŸ”§ Instrument gateway process (#256) (@gernest)
- πŸ”§ #262: adding connection pool for chat request and response (#271) (@tom-fitz)

### Changed

- πŸ”§ #238 Implements human-readable durations in config (#253) (@ppmdo)
- πŸ”§ #266: removing omitempty from response definition (#267) (@tom-fitz)

#### Breaking Changes

- πŸ”§ πŸ’₯ #235: Extended the non-streaming chat error schema with new fields to give clients more context around the error (#236) (@roma-glushko)
- πŸ’₯ Convert all camelCase config fields to the snake_case in the provider configs (#260) (@roma-glushko)
- ✨πŸ’₯ #153: Allow to pass multiple model-specific param overrides (#264) (@roma-glushko)

### Fixed

- πŸ› #217: Set build info correctly in Glide images (#218) (@roma-glushko)

### Security

- πŸ”’ Updated golang to 1.22.4 to address CVE-2024-24790 (#276) (@STAR-173)

### Miscellaneous

- πŸ“ Defined a way to manage EinStack Glide project (#234) (@roma-glushko)
- πŸ‘· #219: Setup local telemetry stack with Jaeger, Grafana, VictoriaMetrics and OTEL Collector (#225) (@roma-glushko)
- πŸ‘·β€β™‚οΈ Added a new GH action to watch for glide activity stream (#239, #244) (@roma-glushko)
- ✨ Switched to the new docs (@roma-glushko)
- πŸ”§ #240: Automatically install air (#277, #270) (@ppmdo, @roma-glushko)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:telemetry Logging, metrics, traces type:enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

πŸ”§ [Telemetry] Setup OTEL Tracer(s) and Meter(s)
2 participants