Skip to content

Commit 8595942

Browse files
authored
Merge branch 'main' into feat/nodejs/update-auto-instrumentation-defaults
2 parents 1ad32c1 + 793ba52 commit 8595942

File tree

20 files changed

+785
-130
lines changed

20 files changed

+785
-130
lines changed

.github/workflows/ci-python.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ jobs:
3131
matrix:
3232
# If you add a python version here, please make sure that the collector/Makefile publish and publish-layer targets
3333
# get updated as well
34-
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
34+
python: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
3535

3636
steps:
3737
- name: Checkout this repo
3838
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3939
- name: Setup Python for OTel Python SDK
40-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
40+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
4141
with:
4242
python-version: ${{ matrix.python }}
4343
- name: Install tox testing package

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868

6969
# Initializes the CodeQL tools for scanning.
7070
- name: Initialize CodeQL
71-
uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v3.29.5
71+
uses: github/codeql-action/init@fe4161a26a8629af62121b670040955b330f9af2 # v3.29.5
7272
with:
7373
languages: ${{ matrix.target.language }}
7474
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -82,7 +82,7 @@ jobs:
8282
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
8383
# If this step fails, then you should remove it and run the build manually (see below)
8484
- name: Autobuild
85-
uses: github/codeql-action/autobuild@fdbfb4d2750291e159f0156def62b853c2798ca2 # v3.29.5
85+
uses: github/codeql-action/autobuild@fe4161a26a8629af62121b670040955b330f9af2 # v3.29.5
8686
with:
8787
working-directory: ${{ matrix.target.directory }}
8888
# There are no array literals in GHA that is why we need to use fromJson.
@@ -114,7 +114,7 @@ jobs:
114114
if: ${{ matrix.target.language == 'java' }}
115115

116116
- name: setup dotnet
117-
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
117+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
118118
with:
119119
dotnet-version: 6.x
120120
if: ${{ matrix.target.language == 'csharp' }}
@@ -126,6 +126,6 @@ jobs:
126126
if: ${{ matrix.target.language == 'csharp' }}
127127

128128
- name: Perform CodeQL Analysis
129-
uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v3.29.5
129+
uses: github/codeql-action/analyze@fe4161a26a8629af62121b670040955b330f9af2 # v3.29.5
130130
with:
131131
category: "/language:${{matrix.target.language}}"

.github/workflows/layer-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
with:
9595
name: ${{ inputs.artifact-name }}
9696

97-
- uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 # v5.1.0
97+
- uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1
9898
with:
9999
role-to-assume: ${{ inputs.role-arn || secrets.OTEL_LAMBDA_LAYER_PUBLISH_ROLE_ARN || secrets.PROD_LAMBDA_ROLE_ARN }}
100100
role-duration-seconds: 1200

.github/workflows/ossf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ jobs:
4242
# Upload the results to GitHub's code scanning dashboard (optional).
4343
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
4444
- name: "Upload to code-scanning"
45-
uses: github/codeql-action/upload-sarif@fdbfb4d2750291e159f0156def62b853c2798ca2 # v3.29.5
45+
uses: github/codeql-action/upload-sarif@fe4161a26a8629af62121b670040955b330f9af2 # v3.29.5
4646
with:
4747
sarif_file: results.sarif

.github/workflows/release-layer-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3232

33-
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
33+
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
3434
with:
3535
python-version: '3.9'
3636

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ For more information about the maintainer role, see the [community repository](h
135135
### Approvers
136136

137137
- [Ivan Santos](https://github.com/pragmaticivan)
138+
- [Maxime David](https://github.com/maxday)
138139

139140
For more information about the approver role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#approver).
140141

collector/internal/telemetryapi/listener.go

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ package telemetryapi
1717
import (
1818
"context"
1919
"encoding/json"
20-
"errors"
2120
"fmt"
2221
"io"
23-
"math/rand"
2422
"net"
2523
"net/http"
2624
"os"
27-
"syscall"
2825
"time"
2926

3027
"github.com/golang-collections/go-datastructures/queue"
@@ -33,17 +30,8 @@ import (
3330

3431
const (
3532
initialQueueSize = 5
36-
maxRetries = 5
37-
// Define ephemeral port range (typical range is 49152-65535)
38-
minPort = 49152
39-
maxPort = 65535
4033
)
4134

42-
// getRandomPort returns a random port number within the ephemeral range
43-
func getRandomPort() string {
44-
return fmt.Sprintf("%d", rand.Intn(maxPort-minPort)+minPort)
45-
}
46-
4735
// Listener is used to listen to the Telemetry API
4836
type Listener struct {
4937
httpServer *http.Server
@@ -60,46 +48,39 @@ func NewListener(logger *zap.Logger) *Listener {
6048
}
6149
}
6250

63-
func (s *Listener) tryBindPort() (net.Listener, string, error) {
64-
for i := 0; i < maxRetries; i++ {
65-
port := getRandomPort()
66-
address := listenOnAddress(port)
67-
68-
l, err := net.Listen("tcp", address)
69-
if err != nil {
70-
if errors.Is(err, syscall.EADDRINUSE) {
71-
s.logger.Debug("Port in use, trying another",
72-
zap.String("address", address))
73-
continue
74-
}
75-
return nil, "", err
76-
}
77-
return l, address, nil
51+
func (s *Listener) bindListener() (net.Listener, string, error) {
52+
listenerAddr := listenOnAddress()
53+
l, err := net.Listen("tcp", listenerAddr+":0")
54+
if err != nil {
55+
return nil, "", err
7856
}
79-
80-
return nil, "", fmt.Errorf("failed to find available port after %d attempts", maxRetries)
57+
addr := fmt.Sprintf("%s:%d", listenerAddr, l.Addr().(*net.TCPAddr).Port)
58+
return l, addr, nil
8159
}
8260

83-
func listenOnAddress(port string) string {
61+
func listenOnAddress() string {
8462
envAwsLocal, ok := os.LookupEnv("AWS_SAM_LOCAL")
85-
var addr string
8663
if ok && envAwsLocal == "true" {
87-
addr = ":" + port
64+
return ""
8865
} else {
89-
addr = "sandbox.localdomain:" + port
66+
return "sandbox.localdomain"
9067
}
91-
return addr
9268
}
9369

9470
// Start the server in a goroutine where the log events will be sent
9571
func (s *Listener) Start() (string, error) {
96-
listener, address, err := s.tryBindPort()
72+
listener, address, err := s.bindListener()
9773
if err != nil {
9874
return "", fmt.Errorf("failed to find available port: %w", err)
9975
}
10076
s.logger.Info("Listening for requests", zap.String("address", address))
101-
s.httpServer = &http.Server{Addr: address}
102-
http.HandleFunc("/", s.httpHandler)
77+
mux := http.NewServeMux()
78+
s.httpServer = &http.Server{
79+
Addr: address,
80+
Handler: mux,
81+
}
82+
mux.HandleFunc("/", s.httpHandler)
83+
10384
go func() {
10485
err := s.httpServer.Serve(listener)
10586
if err != http.ErrServerClosed {

0 commit comments

Comments
 (0)