honeycombio / husky

a library for translating other data types to Honeycomb-format data structures
Apache License 2.0
2 stars 10 forks source link

feat: Add tracing support #253

Closed MikeGoldsmith closed 6 months ago

MikeGoldsmith commented 6 months ago

Which problem is this PR solving?

Adds tracing support to Husky that can be configured by library users (eg beeline or otel). This is done by exposing a new global var AddTelemetryAttributeFunc that husky will call internally. The new func receives a context struct and a map of attributes with the library responsible to setting that telemetry on whatever telemetry client being used.

For example, a library user may configure the beeline then set the AddTelemetryAttributeFunc to add the attributes to the current beeline span like this:

husky.AddTelemetryAttributeFunc = func(ctx context.Context, key string, value any) {
    beeline.AddField(ctx, key, value)
}

I would like to make husky just use OTel for tracing, but some consumers are still using beeline and I don’t want to add beeline as a dependency.

Short description of the changes