-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Added Tag Configuration Support Lightstep Tracing #4175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,4 +119,5 @@ config: | |
port: 0 | ||
plaintext: false | ||
custom_ca_cert_file: "" | ||
tags: "" | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package lightstep | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/thanos-io/thanos/pkg/testutil" | ||
|
||
"github.com/opentracing/opentracing-go" | ||
) | ||
|
||
func TestParseTags(t *testing.T) { | ||
type testData struct { | ||
input string | ||
description string | ||
expectedOutput opentracing.Tags | ||
} | ||
|
||
testingData := []testData{ | ||
{ | ||
description: `A very simple case, key "foo" and value "bar"`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. amazing 🤗 |
||
input: "foo=bar", | ||
expectedOutput: opentracing.Tags{"foo": "bar"}, | ||
}, | ||
{ | ||
description: `A simple case multiple keys, keys ["foo", "bar"] and values ["foo", "bar"]`, | ||
input: "foo=foo,bar=bar", | ||
expectedOutput: opentracing.Tags{"foo": "foo", "bar": "bar"}, | ||
}, | ||
{ | ||
description: `A case with empty environment variable, key "foo" and value ""`, | ||
input: "foo=${TEST:}", | ||
expectedOutput: opentracing.Tags{"foo": ""}, | ||
}, | ||
{ | ||
description: `A case with empty environment variable, key "foo" and value ""`, | ||
input: "foo=${TEST:}", | ||
expectedOutput: opentracing.Tags{"foo": ""}, | ||
}, | ||
{ | ||
description: `A case with default environment variable, key "foo" and value "default"`, | ||
input: "foo=${TEST:default}", | ||
expectedOutput: opentracing.Tags{"foo": "default"}, | ||
}, | ||
{ | ||
description: `A case with real environment variable, key "foo" and value "env-bar"`, | ||
input: "foo=${_TEST_PARSE_TAGS:default}", | ||
expectedOutput: opentracing.Tags{"foo": "env-bar"}, | ||
}, | ||
} | ||
|
||
os.Setenv("_TEST_PARSE_TAGS", "env-bar") | ||
for _, test := range testingData { | ||
t.Logf("testing %s\n", test.description) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a biggy, but we can use |
||
testutil.Equals(t, test.expectedOutput, parseTags(test.input)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a quick unit-test for it? (:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about that 😜 But there aren't any other unit tests in the tracing package (except stackdriver), so I figured it didn't make sense to break that ground for this simple change.
Should we add in a testing file and scaffolding for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch all that... I went ahead and added testing. PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haaa, yea, something pragmatic would work, e.g just testing parsting tags (: Like what you did! Thanks!