Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rajrang/aadEnhance
Browse files Browse the repository at this point in the history
  • Loading branch information
rajkumar-rangaraj committed Nov 13, 2023
2 parents a06596e + 78da59a commit e8d48b9
Show file tree
Hide file tree
Showing 36 changed files with 894 additions and 115 deletions.
27 changes: 27 additions & 0 deletions .chloggen/datadog-connector-mutates-data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: datadogconnector

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Mark datadogconnector as `MutatesData` to prevent data race"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [29111]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
27 changes: 27 additions & 0 deletions .chloggen/issue-27897-IsBool-Converter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/ottl

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add IsBool function into OTTL

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [27897]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
28 changes: 28 additions & 0 deletions .chloggen/mx-psi_change-to-string.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: processor/resourcedetection

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add `processor.resourcedetection.hostCPUModelAndFamilyAsString` feature gate to change the type of `host.cpu.family` and `host.cpu.model.id` attributes from `int` to `string`.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [29025]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
This feature gate will graduate to beta in the next release.
# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
27 changes: 27 additions & 0 deletions .chloggen/pkg-stanza-input-udp-async-fix-data-corruption.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/stanza

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix data-corruption/race-condition issue in udp async (reuse of buffer); use buffer pool isntead.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [27613]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
27 changes: 27 additions & 0 deletions .chloggen/telemetrygen-logs-http.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: cmd/telemetrygen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for --otlp-http for telemetrygen logs

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [18867]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
38 changes: 19 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,25 +313,25 @@ triaged and is ready for work. If someone who is assigned to an issue is no long
### Label Definitions
| Label | When to apply |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bug` | Something that is advertised or intended to work isn't working as expected. |
| `enhancement` | Something that isn't an advertised feature that would be useful to users or maintainers. |
| `flaky test` | A test unexpectedly failed during CI, showing that there is a problem with the tests or test setup that is causing the tests to intermittently fail. |
| `documentation` | This is a collector usability issue that could likely be resolved by providing relevant documentation. Please consider adding new or improving existing documentation before closing issues with this label. |
| `good first issue` | Implementing this issue would not require specialized or in-depth knowledge about the component and is ideal for a new or first-time contributor to take. |
| `help wanted` | The code owners for this component do not expect to have time to work on it soon, and would welcome help from contributors. |
| `discussion needed` | This issue needs more input from the maintainers or community before work can be started. |
| `needs triage` | This label is added automatically, and can be removed when a triager or code owner deems that an issue is either ready for work or should not need any work. |
| `waiting for author` | Can be applied when input is required from the author before the issue can move any further. |
| `priority:p0` | A critical security vulnerability or Collector panic using a default or common configuration unrelated to a specific component. |
| `priority:p1` | An urgent issue that should be worked on quickly, before most other issues. |
| `priority:p2` | A standard bug or enhancement. |
| `priority:p3` | A technical improvement, lower priority bug, or other minor issue. Generally something that is considered a "nice to have." |
| `release:blocker` | This issue must be resolved before the next Collector version can be released. |
| `Sponsor Needed` | A new component has been proposed, but implementation is not ready to begin. This can be because a sponsor has not yet been decided, or because some details on the component still need to be decided. |
| `Accepted Component` | A sponsor has elected to take on a component and implementation is ready to begin. |
| `Vendor Specific Component` | This should be applied to any component proposal where the functionality for the component is particular to a vendor. |
| Label | When to apply |
| -------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `bug` | Something that is advertised or intended to work isn't working as expected. |
| `enhancement` | Something that isn't an advertised feature that would be useful to users or maintainers. |
| `flaky test` | A test unexpectedly failed during CI, showing that there is a problem with the tests or test setup that is causing the tests to intermittently fail. |
| `documentation` | This is a collector usability issue that could likely be resolved by providing relevant documentation. Please consider adding new or improving existing documentation before closing issues with this label. |
| `good first issue` | Implementing this issue would not require specialized or in-depth knowledge about the component and is ideal for a new or first-time contributor to take. |
| `help wanted` | The code owners for this component do not expect to have time to work on it soon, and would welcome help from contributors. |
| `discussion needed` | This issue needs more input from the maintainers or community before work can be started. |
| `needs triage` | This label is added automatically, and can be removed when a triager or code owner deems that an issue is either ready for work or should not need any work. See also the [triaging process](#triage-process). |
| `waiting for author` | Can be applied when input is required from the author before the issue can move any further. |
| `priority:p0` | A critical security vulnerability or Collector panic using a default or common configuration unrelated to a specific component. |
| `priority:p1` | An urgent issue that should be worked on quickly, before most other issues. |
| `priority:p2` | A standard bug or enhancement. |
| `priority:p3` | A technical improvement, lower priority bug, or other minor issue. Generally something that is considered a "nice to have." |
| `release:blocker` | This issue must be resolved before the next Collector version can be released. |
| `Sponsor Needed` | A new component has been proposed, but implementation is not ready to begin. This can be because a sponsor has not yet been decided, or because some details on the component still need to be decided. |
| `Accepted Component` | A sponsor has elected to take on a component and implementation is ready to begin. |
| `Vendor Specific Component` | This should be applied to any component proposal where the functionality for the component is particular to a vendor. |
### Adding Labels via Comments
Expand Down
1 change: 0 additions & 1 deletion cmd/checkapi/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ extension/observer
processor/servicegraphprocessor
receiver/journaldreceiver
receiver/kafkareceiver
receiver/windowseventlogreceiver
4 changes: 2 additions & 2 deletions cmd/telemetrygen/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

// TestConfig_HTTPPath verifies that the HTTPPath configuration defaults are correctly set for each sub-command.
func TestConfig_HTTPPath(t *testing.T) {
t.Run("LogsConfigEmptyDefaultUrlPath", func(t *testing.T) {
assert.Equal(t, "", logsCfg.HTTPPath)
t.Run("LogsConfigValidDefaultUrlPath", func(t *testing.T) {
assert.Equal(t, "/v1/logs", logsCfg.HTTPPath)
})

t.Run("MetricsConfigValidDefaultUrlPath", func(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions cmd/telemetrygen/internal/logs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type Config struct {
// Flags registers config flags.
func (c *Config) Flags(fs *pflag.FlagSet) {
c.CommonFlags(fs)

fs.StringVar(&c.HTTPPath, "otlp-http-url-path", "/v1/logs", "Which URL path to write to")

fs.IntVar(&c.NumLogs, "logs", 1, "Number of logs to generate in each worker (ignored if duration is provided)")
fs.StringVar(&c.Body, "body", "the message", "Body of the log")
}
93 changes: 93 additions & 0 deletions cmd/telemetrygen/internal/logs/exporter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package logs

import (
"bytes"
"context"
"fmt"
"io"
"net/http"

"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/plog/plogotlp"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

type exporter interface {
export(plog.Logs) error
}

func newExporter(ctx context.Context, cfg *Config) (exporter, error) {
if cfg.UseHTTP {
return &httpClientExporter{
client: http.DefaultClient,
cfg: cfg,
}, nil
}

if !cfg.Insecure {
return nil, fmt.Errorf("'telemetrygen logs' only supports insecure gRPC")
}
// only support grpc in insecure mode
clientConn, err := grpc.DialContext(ctx, cfg.Endpoint(), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, err
}
return &gRPCClientExporter{client: plogotlp.NewGRPCClient(clientConn)}, nil
}

type gRPCClientExporter struct {
client plogotlp.GRPCClient
}

func (e *gRPCClientExporter) export(logs plog.Logs) error {
req := plogotlp.NewExportRequestFromLogs(logs)
if _, err := e.client.Export(context.Background(), req); err != nil {
return err
}
return nil
}

type httpClientExporter struct {
client *http.Client
cfg *Config
}

func (e *httpClientExporter) export(logs plog.Logs) error {
scheme := "https"
if e.cfg.Insecure {
scheme = "http"
}
path := e.cfg.HTTPPath
url := fmt.Sprintf("%s://%s%s", scheme, e.cfg.Endpoint(), path)

req := plogotlp.NewExportRequestFromLogs(logs)
body, err := req.MarshalProto()
if err != nil {
return fmt.Errorf("failed to marshal logs to protobuf: %w", err)
}

httpReq, err := http.NewRequestWithContext(context.Background(), "POST", url, bytes.NewReader(body))
if err != nil {
return fmt.Errorf("failed to create logs HTTP request: %w", err)
}
for k, v := range e.cfg.Headers {
httpReq.Header.Set(k, v)
}
httpReq.Header.Set("Content-Type", "application/x-protobuf")
resp, err := e.client.Do(httpReq)
if err != nil {
return fmt.Errorf("failed to execute logs HTTP request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
var respData bytes.Buffer
_, _ = io.Copy(&respData, resp.Body)
return fmt.Errorf("log request failed with status %s (%s)", resp.Status, respData.String())
}

return nil
}
Loading

0 comments on commit e8d48b9

Please sign in to comment.