Skip to content
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

Integrate collector with new metadata api #858

Merged
merged 37 commits into from
Jan 9, 2023
Merged

Conversation

portertech
Copy link
Contributor

@portertech portertech commented Dec 3, 2022

Integrated the collector with the new metadata API. Update the collector's metadata on every process start, before the heartbeat loop is initialized. Metadata is important to the user experience, errors result in retries with back-off.

Spec doc.

Jira ticket.

This feature uses a gate (for now), you must enable it via the CLI with the --feature-gates flag. For example:

otelcol-sumo ... --feature-gates=+extension.sumologic.updateCollectorMetadata

Signed-off-by: Sean Porter <portertech@gmail.com>
@github-actions github-actions bot added the go label Dec 3, 2022
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Dec 8, 2022
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
…rk proxy info

Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
@portertech portertech marked this pull request as ready for review January 3, 2023 06:08
@portertech portertech requested a review from a team as a code owner January 3, 2023 06:08
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Comment on lines +1 to +37
// 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
//
// http://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.

package api

type OpenMetadataHostDetails struct {
Name string `json:"name"`
OsName string `json:"osName"`
OsVersion string `json:"osVersion"`
Environment string `json:"environment"`
}

type OpenMetadataCollectorDetails struct {
RunningVersion string `json:"runningVersion"`
}

type OpenMetadataNetworkDetails struct {
HostIpAddress string `json:"hostIpAddress"`
}

type OpenMetadataRequestPayload struct {
HostDetails OpenMetadataHostDetails `json:"hostDetails"`
CollectorDetails OpenMetadataCollectorDetails `json:"collectorDetails"`
NetworkDetails OpenMetadataNetworkDetails `json:"networkDetails"`
TagDetails map[string]interface{} `json:"tagDetails"`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we going to change api in the futher? Do we need any kind of versioning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe so, there may be additional fields. I used registration for reference.

Copy link
Contributor

@swiatekm-sumo swiatekm-sumo left a comment

Choose a reason for hiding this comment

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

Looks good to me overall, left some minor comments.

pkg/extension/sumologicextension/extension.go Outdated Show resolved Hide resolved
pkg/extension/sumologicextension/extension.go Outdated Show resolved Hide resolved

se.logger.Info("Updating collector metadata",
zap.String("URL", u.String()),
zap.String("body", buff.String()))
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're going to log this, we should make sure that it's human-readable. Setting an indentation level on the encoder should suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Zap String() doesn't pretty print it as expected, for example: {\n\t\t\"runningVersion\":

Copy link
Contributor Author

@portertech portertech Jan 6, 2023

Choose a reason for hiding this comment

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

This logging is really for our own testing, it should moved to debug or be removed when we remove the feature gate.

pkg/extension/sumologicextension/extension.go Outdated Show resolved Hide resolved
portertech and others added 4 commits January 5, 2023 14:46
Co-authored-by: Mikołaj Świątek <mswiatek@sumologic.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
Signed-off-by: Sean Porter <portertech@gmail.com>
@portertech portertech merged commit ef83074 into main Jan 9, 2023
@portertech portertech deleted the feature/metadata-api branch January 9, 2023 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation go
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants