-
Notifications
You must be signed in to change notification settings - Fork 994
feat(exporter-collector): support config from env #2099 #2117
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
68c8d18
chore(core): export baggage utils
vmarchaud 2865aab
feat(exporter-collector): support config from env #2099
vmarchaud a64c6f6
feat(exporter-collector-proto): support config from env
vmarchaud 0e7bf61
feat(exporter-collector-grpc): support config from env
vmarchaud 91f93ec
chore: rechange default http port to 55681
vmarchaud 36481d6
chore(docs): update tested collector version
vmarchaud 6dd634d
chore: prefix baggage constants
vmarchaud f4e1bb7
Merge branch 'main' into collector-config-env
vmarchaud 4b2033d
Merge branch 'main' into collector-config-env
dyladan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| export const BAGGAGE_KEY_PAIR_SEPARATOR = '='; | ||
| export const BAGGAGE_PROPERTIES_SEPARATOR = ';'; | ||
| export const BAGGAGE_ITEMS_SEPARATOR = ','; | ||
|
|
||
| // Name of the http header used to propagate the baggage | ||
| export const BAGGAGE_HEADER = 'baggage'; | ||
| // Maximum number of name-value pairs allowed by w3c spec | ||
| export const BAGGAGE_MAX_NAME_VALUE_PAIRS = 180; | ||
| // Maximum number of bytes per a single name-value pair allowed by w3c spec | ||
| export const BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = 4096; | ||
| // Maximum total length of all name-value pairs allowed by w3c spec | ||
| export const BAGGAGE_MAX_TOTAL_LENGTH = 8192; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| import { Baggage, baggageEntryMetadataFromString } from '@opentelemetry/api'; | ||
| import { | ||
| BAGGAGE_ITEMS_SEPARATOR, | ||
| BAGGAGE_PROPERTIES_SEPARATOR, | ||
| BAGGAGE_KEY_PAIR_SEPARATOR, | ||
| BAGGAGE_MAX_TOTAL_LENGTH, | ||
| } from './constants'; | ||
|
|
||
| export const serializeKeyPairs = (keyPairs: string[]) => { | ||
| return keyPairs.reduce((hValue: string, current: string) => { | ||
| const value = `${hValue}${ | ||
| hValue !== '' ? BAGGAGE_ITEMS_SEPARATOR : '' | ||
| }${current}`; | ||
| return value.length > BAGGAGE_MAX_TOTAL_LENGTH ? hValue : value; | ||
| }, ''); | ||
| }; | ||
|
|
||
| export const getKeyPairs = (baggage: Baggage): string[] => { | ||
| return baggage | ||
| .getAllEntries() | ||
| .map( | ||
| ([key, value]) => | ||
| `${encodeURIComponent(key)}=${encodeURIComponent(value.value)}` | ||
| ); | ||
| }; | ||
|
|
||
| export const parsePairKeyValue = (entry: string) => { | ||
| const valueProps = entry.split(BAGGAGE_PROPERTIES_SEPARATOR); | ||
| if (valueProps.length <= 0) return; | ||
| const keyPairPart = valueProps.shift(); | ||
| if (!keyPairPart) return; | ||
| const keyPair = keyPairPart.split(BAGGAGE_KEY_PAIR_SEPARATOR); | ||
| if (keyPair.length !== 2) return; | ||
| const key = decodeURIComponent(keyPair[0].trim()); | ||
| const value = decodeURIComponent(keyPair[1].trim()); | ||
| let metadata; | ||
| if (valueProps.length > 0) { | ||
| metadata = baggageEntryMetadataFromString( | ||
| valueProps.join(BAGGAGE_PROPERTIES_SEPARATOR) | ||
| ); | ||
| } | ||
| return { key, value, metadata }; | ||
| }; | ||
|
|
||
| /** | ||
| * Parse a string serialized in the baggage HTTP Format (without metadata): | ||
| * https://github.com/w3c/baggage/blob/master/baggage/HTTP_HEADER_FORMAT.md | ||
| */ | ||
| export const parseKeyPairsIntoRecord = (value?: string) => { | ||
| if (typeof value !== 'string' || value.length === 0) return {}; | ||
| return value | ||
| .split(BAGGAGE_ITEMS_SEPARATOR) | ||
| .map(entry => { | ||
| return parsePairKeyValue(entry); | ||
| }) | ||
| .filter(keyPair => keyPair !== undefined && keyPair.value.length > 0) | ||
| .reduce<Record<string, string>>((headers, keyPair) => { | ||
| headers[keyPair!.key] = keyPair!.value; | ||
| return headers; | ||
| }, {}); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.