Skip to content

Add a config source manager - #2857

Merged
tigrannajaryan merged 5 commits into
open-telemetry:mainfrom
pjanotti:add-config-source-manager
Apr 7, 2021
Merged

Add a config source manager#2857
tigrannajaryan merged 5 commits into
open-telemetry:mainfrom
pjanotti:add-config-source-manager

Conversation

@pjanotti

Copy link
Copy Markdown
Contributor

Adds a config source manager that wraps the interaction with config sources. This should be the part visible outside the configuration-related implementation, ie.: for the code setting up the service and watching for updates.

The syntax for config source references is provisional.

@pjanotti
pjanotti requested a review from a team March 30, 2021 17:41
@codecov

codecov Bot commented Mar 30, 2021

Copy link
Copy Markdown

Codecov Report

Merging #2857 (e560941) into main (c5ddd09) will decrease coverage by 0.07%.
The diff coverage is 82.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2857      +/-   ##
==========================================
- Coverage   91.74%   91.66%   -0.08%     
==========================================
  Files         286      287       +1     
  Lines       15086    15221     +135     
==========================================
+ Hits        13841    13953     +112     
- Misses        851      865      +14     
- Partials      394      403       +9     
Impacted Files Coverage Δ
config/internal/configsource/manager.go 82.96% <82.96%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5ddd09...e560941. Read the comment docs.

m.sessions[cfgSrcName] = session
}

retrieved, err := session.Retrieve(ctx, selector, params)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a blocking call? So we will not indicate in any way that there is an ongoing retrieval from a remote source, which potentially can take a lot of time. If so perhaps in the future we should add some sort of logging or something to show this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is potentially a blocking call as is the NewSession. I will add a parameter to create the manager to include the logger as we typically flow it to components.

Comment thread config/internal/configsource/manager.go
return nil, fmt.Errorf("config source %q not found", cfgSrcName)
}

session, err = cfgSrc.NewSession(ctx)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For ConfigSource.NewSession docs say:

// The code managing the returned Session object must guarantee that the object is not used
// concurrently and that a single ConfigSource only have one Session open at any time.

Are we violating the second requirement here? If the same cfgSourceName is referenced from multiple places then we are creating multiple sessions, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm treating the config sources as named entities. Let me try to clarify with a hypothetical example:

config_sources:
  vault/db:
    path: secret/db
  vault/users:
    path: secret/users

Then on usage, there should be one session for vault/db and another for vault/users when they are referenced on the config:

exporter:
  db_exporter:
    token: $vault/db:data.token
  some_exporter:
    username: $vault/users:data.traceruser
    password: $vault/users:data.tracerpwd

@pjanotti
pjanotti force-pushed the add-config-source-manager branch from 82c4d1c to e560941 Compare April 6, 2021 20:05
@pjanotti

pjanotti commented Apr 6, 2021

Copy link
Copy Markdown
Contributor Author

Changed the single-line format to have the parameters like URL query part and add multi-line support.

@tigrannajaryan tigrannajaryan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Just to be clear, we are not breaking $env or ${env} existing syntax, do we?

@pjanotti

pjanotti commented Apr 7, 2021

Copy link
Copy Markdown
Contributor Author

LGTM. Just to be clear, we are not breaking $env or ${env} existing syntax, do we?

Currently, it is. I will fix it before hooking it up for actual usage.

@tigrannajaryan
tigrannajaryan merged commit 8cac172 into open-telemetry:main Apr 7, 2021
@pjanotti
pjanotti deleted the add-config-source-manager branch April 7, 2021 19:32
tigrannajaryan pushed a commit that referenced this pull request Apr 9, 2021
ravularohit pushed a commit to ravularohit/opentelemetry-collector-contrib that referenced this pull request Jun 25, 2026
zeekay pushed a commit to hanzoai/telemetry that referenced this pull request Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants