Skip to content

[FEAT] Extend Analytics Interface #3382

@gregfurman

Description

@gregfurman

Is your feature request related to a problem? Please describe.

The Analytcis interface is quite constrained in its functionality. For example, if I wanted to count multiple times, I'd have to either call Count(...) in a loop (without concern for spamming the span table) OR try and set my value within properties.Properties as a label/attribute, unnecessarily increasing cardinality.

Describe the solution you'd like

Extend the offering of the analytics package and associated Analytics interface to instead accept more types and options for recording of metrics/data/analytics.

i.e

// could make a private Property interface to ensure whatever props we pass in are valid i.e

type Property interface {
	private()
}

type Properties map[string]interface{}
func (Properties) private() {}

type Increment int
func (Increment) private() {}

type Analytics interface {
   // ...
   Count(ctx context.Context, resource Resource, action Action, props ...Property)
   // ...
}

Then we can increment this like:

oc.a.Count(ctx, analytics.OtelSpan, analytics.Create, analytics.Increment(len(spans)))

Describe alternatives you've considered

None that don't either require extending the interface or introducing some breaking changes.

Additional context

Follow-up from discussion in #3375 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgoPull requests that update Go code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions