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

[jaeger-v2] Add remotesampling extension #5389

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Pushkarm029
Copy link
Member

@Pushkarm029 Pushkarm029 commented Apr 25, 2024

Description of the changes

How was this change tested?

  • go run -tags=ui ./cmd/jaeger --config ./cmd/jaeger/config-badger.yaml
  • make test

Checklist

@Pushkarm029 Pushkarm029 requested a review from a team as a code owner April 25, 2024 17:11
Copy link

codecov bot commented Apr 25, 2024

Codecov Report

Attention: Patch coverage is 26.73611% with 211 lines in your changes missing coverage. Please review.

Project coverage is 95.15%. Comparing base (1c1bc08) to head (1a2c505).

Files Patch % Lines
...ger/internal/extension/remotesampling/extension.go 29.33% 91 Missing and 15 partials ⚠️
.../internal/processors/adaptivesampling/processor.go 0.00% 35 Missing ⚠️
...er/internal/processors/adaptivesampling/factory.go 0.00% 20 Missing ⚠️
...jaeger/internal/extension/remotesampling/config.go 15.00% 15 Missing and 2 partials ⚠️
...ugin/sampling/strategyprovider/adaptive/options.go 0.00% 13 Missing ⚠️
...n/sampling/strategyprovider/adaptive/aggregator.go 0.00% 10 Missing ⚠️
pkg/clientcfg/clientcfghttp/handler.go 0.00% 7 Missing ⚠️
...ger/internal/processors/adaptivesampling/config.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5389      +/-   ##
==========================================
- Coverage   96.38%   95.15%   -1.23%     
==========================================
  Files         329      335       +6     
  Lines       16060    16347     +287     
==========================================
+ Hits        15479    15555      +76     
- Misses        404      598     +194     
- Partials      177      194      +17     
Flag Coverage Δ
badger_v1 8.04% <ø> (ø)
badger_v2 1.92% <0.00%> (ø)
cassandra-3.x-v1 16.60% <ø> (ø)
cassandra-3.x-v2 1.84% <0.00%> (ø)
cassandra-4.x-v1 16.60% <ø> (ø)
cassandra-4.x-v2 1.84% <0.00%> (ø)
elasticsearch-7.x-v1 18.87% <ø> (-0.02%) ⬇️
elasticsearch-8.x-v1 19.07% <ø> (ø)
elasticsearch-8.x-v2 19.07% <ø> (-0.02%) ⬇️
grpc_v1 9.47% <ø> (ø)
grpc_v2 7.47% <0.00%> (-0.02%) ⬇️
kafka 9.76% <ø> (ø)
opensearch-1.x-v1 18.93% <ø> (ø)
opensearch-2.x-v1 18.93% <ø> (ø)
opensearch-2.x-v2 18.92% <ø> (ø)
unittests 93.04% <26.73%> (-1.19%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Pushkarm029
Copy link
Member Author

I am thinking of this approach.:

  • create a gRPC sampling server
  • then, register api_v2.RegisterSamplingManagerServer(server, sampling.NewGRPCHandler(SamplingStore))
  • similarly, create an HTTP server and register a sampling API.

That's how it works in the current Jaeger collector, but we are serving this API in the collector server. Here, we have to create a new one.

suggestions

@Pushkarm029
Copy link
Member Author

One more question:

How can I run hotrod with jaeger-v2 binary?
I tried this, but Jaeger UI was not able to detect Hotrod service.
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 go run ./main.go all
go run -tags=ui ./cmd/jaeger --config ./cmd/jaeger/config-elasticsearch.yaml

@yurishkuro
Copy link
Member

We need a remotesampling extension which performs the following duties:

  • creates HTTP server that returns sampling strategies as JSON
  • allows user a choice of a sampling strategy store
    • file: a static file with auto-reload
    • adaptive: a backend storage that implements interfaces in sampling/strategystore package

We also need an adaptivesampling processor that

  • uses remotesampling to obtain storage backend (similar how jaegerexporter uses jaegerextension to get storage)
  • process spans and updates strategies in that storage (which then will be read by the extension's server)

All of this should require very minimal implementation, primarily just wiring up the existing components already implemented in app/collector/main

@yurishkuro
Copy link
Member

The existing component (from jaeger v1) are in blue:

flowchart LR
    Receiver --> AdaptiveSamplingProcessor --> BatchProcessor --> Exporter
    Exporter -->|"(1) get storage"| JaegerStorageExension
    Exporter -->|"(2) write trace"| TraceStorage
    AdaptiveSamplingProcessor -->|"getStorage()"| StorageConfig

    OTEL_SDK[OTEL
             SDK]
    OTEL_SDK -->|"(1) GET /sampling"| HTTP_endpoint
    HTTP_endpoint -->|"(2) getStrategy()"| StrategiesProvider
    style HTTP_endpoint fill:blue,color:white

    subgraph Jaeger Collector
        Receiver
        BatchProcessor[Batch
                       Processor]
        Exporter        
        TraceStorage[(Trace
                      Storage)]
        AdaptiveSamplingProcessor[Adaptive
                                  Sampling
                                  Processor]
        AdaptiveSamplingProcessorV1[Adaptive
                                    Sampling
                                    Processor_v1]
        style AdaptiveSamplingProcessorV1 fill:blue,color:white
        AdaptiveSamplingProcessor -->|"[]*model.Span"| AdaptiveSamplingProcessorV1
        AdaptiveSamplingProcessorV1 ---|use| SamplingStorage

        subgraph JaegerStorageExension[Jaeger Storage Exension]
            Storage[[Storage
                     Config]]
        end
        subgraph RemoteSamplingExtension[Remote Sampling Extension]
            StrategiesProvider -->|"(3b) getStrategy()"| AdaptiveProvider
            StrategiesProvider -->|"(3a) getStrategy()"| FileProvider
            FileProvider --> FileConfig
            AdaptiveProvider --> StorageConfig
    
            HTTP_endpoint[HTTP
                          endpoint]
            StrategiesProvider[Strategies
                               Provider]
            FileProvider[File
                         Provider]
            AdaptiveProvider[Adaptive
                             Provider]
            style StrategiesProvider fill:blue,color:white
            style FileProvider fill:blue,color:white
            style AdaptiveProvider fill:blue,color:white
            subgraph Config
                FileConfig[[File Config]]
                StorageConfig[[Storage Config]]
            end
            StorageConfig --- SamplingStorage
            SamplingStorage[(Sampling
                             Storage)]
            style SamplingStorage fill:blue,color:white
        end
    end
Loading

@Pushkarm029 Pushkarm029 changed the title [jaeger-v2] Add static sampling extension [jaeger-v2] Add remotesampling extension May 4, 2024
@Pushkarm029 Pushkarm029 marked this pull request as draft May 4, 2024 08:11
@Pushkarm029
Copy link
Member Author

i haven;t pushed latest changes yet.

@yurishkuro yurishkuro added the changelog:new-feature Change that should be called out as new feature in CHANGELOG label May 7, 2024
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

looks good, in the right direction

cmd/jaeger/config-badger.yaml Outdated Show resolved Hide resolved
cmd/jaeger/config-badger.yaml Outdated Show resolved Hide resolved
cmd/jaeger/internal/extension/remotesampling/config.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/extension/remotesampling/factory.go Outdated Show resolved Hide resolved
pkg/clientcfg/clientcfghttp/handler.go Outdated Show resolved Hide resolved
pkg/clientcfg/clientcfghttp/handler.go Outdated Show resolved Hide resolved
yurishkuro pushed a commit that referenced this pull request May 21, 2024
## Which problem is this PR solving?
- part of #5389

## Description of the changes
- processor is co-located in strategy_store and aggregator.
- In aggregator to run `generateStrategyResponses`,
`runCalculationLoop`.
- In strategy_store to run `loadProbabilities`,
`runUpdateProbabilitiesLoop`

## How was this change tested?
- `make test`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Pushkar Mishra <[email protected]>
Signed-off-by: pushkarm029 <[email protected]>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

how do you plan to test it?

cmd/jaeger/internal/extension/remotesampling/config.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/extension/remotesampling/factory.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/processors/adaptivesampling/config.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/processors/adaptivesampling/config.go Outdated Show resolved Hide resolved
plugin/sampling/strategystore/adaptive/aggregator.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/extension/remotesampling/extension.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/extension/remotesampling/extension.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/extension/remotesampling/extension.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/extension/remotesampling/extension.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/extension/remotesampling/extension.go Outdated Show resolved Hide resolved
Comment on lines 12 to 13
# file:
# path: ./cmd/jaeger/sampling-strategies.json
Copy link
Member

Choose a reason for hiding this comment

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

maybe we should default to file, not to more complex adaptive?

yurishkuro pushed a commit that referenced this pull request May 26, 2024
## Which problem is this PR solving?
-
#5389 (comment)

## Description of the changes
- Refactored `handleRootSpan` logic into a helper method in
aggregator.go.
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

please fix the DCO and keep it green

cmd/jaeger/internal/extension/remotesampling/extension.go Outdated Show resolved Hide resolved
varshith257 pushed a commit to varshith257/jaeger that referenced this pull request Jun 2, 2024
## Which problem is this PR solving?
-
jaegertracing#5389 (comment)

## Description of the changes
- Refactored `handleRootSpan` logic into a helper method in
aggregator.go.


Signed-off-by: Vamshi Maskuri <[email protected]>
@yurishkuro
Copy link
Member

@Pushkarm029 are you able to fix DCO? It's confused by many unrelated changes.

I would recommend squashing all commit, e.g.

git reset --soft HEAD~40  # to the start of your changes
git stash # save the diffs
git rebase main # (make sure main is up to date before doing this)
git stash apply # may need to resolve a couple of conflicts

Signed-off-by: pushkarm029 <[email protected]>
@Pushkarm029
Copy link
Member Author

Fixed

Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
@yurishkuro
Copy link
Member

Note for future: I restored most config files to original state, it's too early to introduce adaptive sampling parts into them, we should first validate that with memstore. We can come back to that later - commit adda2b2

Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

@Pushkarm029 this looks to be in a good shape, we just need to bump test coverage. I verified that the server starts and serves sampling strategies over HTTP.

Signed-off-by: Yuri Shkuro <[email protected]>
@Pushkarm029
Copy link
Member Author

@Pushkarm029 this looks to be in a good shape, we just need to bump test coverage. I verified that the server starts and serves sampling strategies over HTTP.

thanks, I will start writing tests now.

@Pushkarm029
Copy link
Member Author

Halfway🛣️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:new-feature Change that should be called out as new feature in CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants