-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: otel tracing #899
Merged
Merged
feat: otel tracing #899
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #899 +/- ##
==========================================
- Coverage 52.79% 52.44% -0.35%
==========================================
Files 551 557 +6
Lines 19221 19421 +200
==========================================
+ Hits 10147 10185 +38
- Misses 8510 8670 +160
- Partials 564 566 +2
|
ecrupper
previously approved these changes
Sep 12, 2024
wass3rw3rk
approved these changes
Sep 12, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
ecrupper
approved these changes
Sep 12, 2024
This was referenced Sep 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this PR adds opt-in OpenTelemetry tracing to the server, often referred to as "OTel".
the main difference is the introduction of the
tracing
package which implements a new set of env flags to enable OTel tracing across (nearly) all of the server's executable code.New Flags
VELA_OTEL_TRACING_ENABLE
false
VELA_OTEL_TRACING_SERVICE_NAME
VELA_OTEL_EXPORTER_OTLP_ENDPOINT
VELA_OTEL_TRACING_EXPORTER_SSL_CERT_PATH
NONE
VELA_OTEL_TRACING_TLS_MIN_VERSION
VELA_OTEL_TRACING_RESOURCE_ATTRIBUTES
key1=<value>,key2=<value>
pairsVELA_OTEL_TRACING_RESOURCE_ENV_ATTRIBUTES
key1=<env_key>,key2=<env_key>
pairsNONE
VELA_OTEL_TRACING_SPAN_ATTRIBUTES
key1=<value>,key2=<value>
pairsNONE
VELA_OTEL_TRACING_TRACESTATE_ATTRIBUTES
key1=<value>,key2=<value>
pairsNONE
VELA_OTEL_TRACING_SAMPLER_RATELIMIT_PER_SECOND
the sampler resource/span attributes offer the flexibility to use restrictive collectors that key off particular fields.
Instrumentation Libraries
the code takes advantage of official opentelemetry instrumentation libraries such as otelgin and otelgorm to automatically create detailed trace payloads using Go's built in
context
system.Propagating context.Context
meaning, as long as the
ctx context.Context
is used properly, spans will automatically be generated and attached to the parent trace that initiated the code execution.this means, if we properly pass along
context
as the first parameter of each function then the instrumentation libraries will magically track the timed execution of these functions. then, if you want additional information attached to spans, you would useSpanFromContext(ctx)
to retrieve the current span, then you can manipulate the attributes attached to it.Trace Sampler Configurations
The
tracing
package allows admins to use env flags to customize the way that Vela samples traces. "Sampling" can be done at the beginning (head sampling) or at the end (tail sampling). For now, Vela samples based on a shared rate limit algorithm usingVELA_OTEL_TRACING_SAMPLER_RATELIMIT_PER_SECOND
In the future, I would like to add more head sampling algorithms like "TraceID Ratio", and a way to ignore no-op endpoints such as
/health
.Example Env Configuration
Example Trace Result
by visiting
<ui>/<org>/builds
it results in a trace that looks like this in Jaeger (http://localhost:16686/trace/0cd1273b6f73a7dd3bdf84a3d28c43d7
)