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

feat(samplers): add deterministic sampler #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MustafaHaddara
Copy link
Contributor

@MustafaHaddara MustafaHaddara commented Jan 23, 2025

Short description of the changes

Adds a deterministic sampler, similar to other Honeycomb distro. Heavily based on honeycombio/honeycomb-opentelemetry-swift#17

That PR never actually used the Sampler; I'm not sure if we need to make changes to HoneycombOptions / somewhere else in the initialization process to actually make use of this.

How to verify that this has the expected result

  • unit tests

@MustafaHaddara MustafaHaddara requested a review from a team as a code owner January 23, 2025 21:49
@MustafaHaddara MustafaHaddara changed the title add deterministic sampler feat(samplers): add deterministic sampler Jan 23, 2025
val context = Context.root()

val sampler = HoneycombDeterministicSampler(args.rate)
val result = sampler.shouldSample(context, traceId, "test", SpanKind.CLIENT, Attributes.empty(), emptyList<LinkData>().toMutableList())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

UNLIKE the Swift PR, here we JUST need a Context instead of a SpanContext. This seems to be a difference in the OTel APIs: the Swift one has a signature:

func shouldSample(
    parentContext: SpanContext?,
    traceId: TraceId,
    name: String,
    kind: SpanKind,
    attributes: [String: AttributeValue],
    parentLinks: [SpanData.Link]
) -> any Decision

whereas the Android one has the signature

fun shouldSample(
    context: Context,
    traceId: String,
    name: String,
    spanKind: SpanKind,
    attributes: Attributes,
    parentLinks: MutableList<LinkData>
): SamplingResult

and there doesn't seem to be a relationship between Context and SpanContext in the Android SDK.

Comment on lines 44 to 52
// private class HoneycombDecision(val decision: SamplingDecision, val attributes: Attributes) : SamplingResult {
// override fun getDecision(): SamplingDecision {
// return decision
// }
//
// override fun getAttributes(): Attributes {
// return attributes
// }
// }
Copy link
Member

Choose a reason for hiding this comment

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

maybe remove this

@MustafaHaddara MustafaHaddara force-pushed the mh/deterministic-sampler branch from ee4dac2 to bf614cc Compare January 24, 2025 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants