Skip to content

Commit

Permalink
move deepCopy to test file
Browse files Browse the repository at this point in the history
Signed-off-by: Aryan Goyal <[email protected]>
  • Loading branch information
ary82 committed Dec 30, 2024
1 parent 7818970 commit cb8d0ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package filesource // import "github.com/open-telemetry/opentelemetry-collector-
import (
"bytes"
"context"
"encoding/gob"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -370,13 +369,3 @@ func (h *samplingProvider) parseStrategy(strategy *strategy) *api_v2.SamplingStr
return defaultStrategyResponse()
}
}

func deepCopy(s *api_v2.SamplingStrategyResponse) *api_v2.SamplingStrategyResponse {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
dec := gob.NewDecoder(&buf)
enc.Encode(*s)
var copyValue api_v2.SamplingStrategyResponse
dec.Decode(&copyValue)
return &copyValue
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package filesource

import (
"bytes"
"context"
"encoding/gob"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -59,6 +61,16 @@ func strategiesJSON(probability float32) string {
return strategy
}

func deepCopy(s *api_v2.SamplingStrategyResponse) *api_v2.SamplingStrategyResponse {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
dec := gob.NewDecoder(&buf)
enc.Encode(*s)
var copyValue api_v2.SamplingStrategyResponse
dec.Decode(&copyValue)
return &copyValue
}

// Returns strategies in JSON format. Used for testing
// URL option for sampling strategies.
func mockStrategyServer(t *testing.T) (*httptest.Server, *atomic.Pointer[string]) {
Expand Down

0 comments on commit cb8d0ff

Please sign in to comment.