-
Notifications
You must be signed in to change notification settings - Fork 947
feat(opentelemetry-configuration): Parse of Configuration File #5875
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 17 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
a6d0fca
parse config file
maryliag f544c93
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js int…
maryliag fcef569
update changelog
maryliag 0f6a05a
add more tests
maryliag eeb69f5
Update experimental/packages/opentelemetry-configuration/src/FileConf…
maryliag cb2cd96
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js int…
maryliag 73fe9af
changes from feedback
maryliag 7a1aec4
create function by paramtre type
maryliag 2297ee9
update package lock
maryliag 97d9013
fix disabled
maryliag 1c3ce03
fix changelog
maryliag a6833d8
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js int…
maryliag 287c395
Merge branch 'main' into config-yml
maryliag de08a18
remove import
maryliag a662970
feat(sampler-composite): add experimental implementation of composite…
maryliag 537e20c
Revert "feat(sampler-composite): add experimental implementation of c…
maryliag b158b36
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js int…
maryliag ba49203
use correct type
maryliag 0192f44
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js int…
maryliag 36051e8
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js int…
maryliag 7524d75
update test
maryliag d695c91
fix lint
maryliag dd72027
Merge branch 'main' into config-yml
maryliag 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
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
79 changes: 79 additions & 0 deletions
79
experimental/packages/opentelemetry-configuration/src/utils.ts
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,79 @@ | ||
| /* | ||
| * 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 { diag } from '@opentelemetry/api'; | ||
| import { inspect } from 'util'; | ||
|
|
||
| /** | ||
| * Retrieves a boolean value from a configuration file parameter. | ||
| * - Trims leading and trailing whitespace and ignores casing. | ||
| * - Returns `undefined` if the value is empty, unset, or contains only whitespace. | ||
| * - Returns `undefined` and a warning for values that cannot be mapped to a boolean. | ||
| * | ||
| * @param {unknown} value - The value from the config file. | ||
| * @returns {boolean} - The boolean value or `false` if the environment variable is unset empty, unset, or contains only whitespace. | ||
| */ | ||
| export function getBooleanFromConfigFile(value: unknown): boolean | undefined { | ||
| const raw = String(value)?.trim().toLowerCase(); | ||
| if (raw === 'true') { | ||
| return true; | ||
| } else if (raw === 'false') { | ||
| return false; | ||
| } else if (raw == null || raw === '') { | ||
| return undefined; | ||
| } else { | ||
| diag.warn(`Unknown value ${inspect(raw)}, expected 'true' or 'false'`); | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves a number from a configuration file parameter. | ||
| * - Returns `undefined` if the environment variable is empty, unset, or contains only whitespace. | ||
| * - Returns `undefined` and a warning if is not a number. | ||
| * - Returns a number in all other cases. | ||
| * | ||
| * @param {unknown} value - The value from the config file. | ||
| * @returns {number | undefined} - The number value or `undefined`. | ||
| */ | ||
| export function getNumberFromConfigFile(value: unknown): number | undefined { | ||
| const raw = String(value)?.trim(); | ||
| if (raw == null || raw.trim() === '') { | ||
| return undefined; | ||
| } | ||
|
|
||
| const n = Number(raw); | ||
| if (isNaN(n)) { | ||
| diag.warn(`Unknown value ${inspect(raw)}, expected a number`); | ||
| return undefined; | ||
| } | ||
|
|
||
| return n; | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves a string from a configuration file parameter. | ||
| * - Returns `undefined` if the environment variable is empty, unset, or contains only whitespace. | ||
| * | ||
| * @param {unknown} value - The value from the config file. | ||
| * @returns {string | undefined} - The string value or `undefined`. | ||
| */ | ||
| export function getStringFromConfigFile(value: unknown): string | undefined { | ||
| const raw = String(value)?.trim(); | ||
| if (value == null || raw === '') { | ||
| return undefined; | ||
| } | ||
| return raw; | ||
| } |
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
1 change: 1 addition & 0 deletions
1
experimental/packages/opentelemetry-configuration/test/fixtures/invalid.yaml
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 @@ | ||
| file_format: "invalid" |
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
2 changes: 2 additions & 0 deletions
2
experimental/packages/opentelemetry-configuration/test/fixtures/short-config.yml
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,2 @@ | ||
| file_format: "1.0-rc.1" | ||
| disabled: false |
Oops, something went wrong.
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.