You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a stepping stone to deal more largely with #44 later.
The use-case for contexts
Currently the runtime context of autometrics embeds a context.Context just because it was needed when we added OpenTelemetry support. Now there's a specific need for contexts:
We want to be able to pass data between function calls (to transmit the traceId for example)
We want to be able to pass arbitrary data (it is the only way to have autometrics work with any instrumented code)
Therefore, instead of always initializing the context to a default one, we want to add the options and ability to create an autometrics.Context:
with a context.Context parent, and/or
with specific key-value pairs embedded (a TraceId and a SpanId)
End goal
Creating a context like that will allow autometrics to fetch any data using its embedded context, therefore enabling autometrics to attach any runtime data to the generated metrics
Support for popular libraries
Doing this will allow, in a second time, to use the function signatures of instrumented functions to detect what popular framework they use. If a function has func hello(ctx *gin.Context) as its signature, we could detect the gin context and generate code that will extract and add this information directly in autometrics. At that point, having tracing info in the metrics would only be one middleware away (the one that calls ctx.Set(autometrics.TraceIdKey, "traceId"))
Being able to do this needs a big refactoring of the internal.generate package though, since it kind of assumes there's only 1 way to generate the //autometrics:defer statement
The text was updated successfully, but these errors were encountered:
This is a stepping stone to deal more largely with #44 later.
The use-case for contexts
Currently the runtime context of autometrics embeds a
context.Context
just because it was needed when we added OpenTelemetry support. Now there's a specific need for contexts:traceId
for example)Therefore, instead of always initializing the context to a default one, we want to add the options and ability to create an autometrics.Context:
context.Context
parent, and/orTraceId
and aSpanId
)End goal
Creating a context like that will allow autometrics to fetch any data using its embedded context, therefore enabling autometrics to attach any runtime data to the generated metrics
Support for popular libraries
Doing this will allow, in a second time, to use the function signatures of instrumented functions to detect what popular framework they use. If a function has
func hello(ctx *gin.Context)
as its signature, we could detect the gin context and generate code that will extract and add this information directly in autometrics. At that point, having tracing info in the metrics would only be one middleware away (the one that callsctx.Set(autometrics.TraceIdKey, "traceId")
)Being able to do this needs a big refactoring of the
internal.generate
package though, since it kind of assumes there's only 1 way to generate the//autometrics:defer
statementThe text was updated successfully, but these errors were encountered: