Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Use a Ruby image >= 3.1, as required by some dependencies like recent nokogiri
FROM ruby:3.2-slim-bookworm

# Prevent interactive prompts from apt
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies required for building gems with native extensions
# and for general development.
# - build-essential: For compiling native extensions
# - git: For cloning repos if needed, although VS Code handles the main clone
# - curl, wget: Useful general tools
# - libxml2-dev, libxslt1-dev: Needed by nokogiri gem
# - zlib1g-dev: Needed by many gems
# - sqlite3, libsqlite3-dev: Needed by some gems that might be transitively included
# - libssl-dev: Needed for secure connections, potentially by some gems
# - pkg-config: Build helper
# - make: Used by the Makefile in the repo
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
wget \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
sqlite3 \
libsqlite3-dev \
libssl-dev \
pkg-config \
make \
zsh \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Comment on lines +18 to +33
Copy link

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 bot Apr 25, 2025

Choose a reason for hiding this comment

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

Code Quality Violation

package libsqlite3-dev should have version pinned (...read more)

When using apt-get install, pin the version to avoid unwanted upgrades and undefined behavior.

View in Datadog  Leave us feedback  Documentation

Comment on lines +18 to +33
Copy link

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 bot May 12, 2025

Choose a reason for hiding this comment

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

⚪ Notice: Code Quality Violation

package zsh should have version pinned (...read more)

When using apt-get install, pin the version to avoid unwanted upgrades and undefined behavior.

View in Datadog  Leave us feedback  Documentation



# (Optional but Recommended) Create a non-root user for development
# This matches the default user setup by Dev Containers 'automatic' creation
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
# Add the new user to the sudo group to allow them to run commands with sudo
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(ALL\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/*
Comment on lines +42 to +49

Choose a reason for hiding this comment

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

Code Quality Violation

package sudo should have version pinned (...read more)

When using apt-get install, pin the version to avoid unwanted upgrades and undefined behavior.

View in Datadog  Leave us feedback  Documentation

Comment on lines +42 to +49
Copy link

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 bot May 12, 2025

Choose a reason for hiding this comment

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

⚪ Notice: Code Quality Violation

package sudo should have version pinned (...read more)

When using apt-get install, pin the version to avoid unwanted upgrades and undefined behavior.

View in Datadog  Leave us feedback  Documentation


# Set Zsh as the default shell for the non-root user
# Needs to be run as root, after the user is created and zsh is installed
RUN chsh -s $(which zsh) ${USERNAME}

# Set the default working directory for subsequent commands and where the project code will be mounted
WORKDIR /workspaces

# Switch to the non-root user
USER $USERNAME

# The project code will be mounted into /workspaces by Dev Containers.
# Dependencies will be installed via postCreateCommand in devcontainer.json
53 changes: 53 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// .devcontainer/devcontainer.json
{
"name": "Fluent Plugin Datadog Dev", // A friendly name
// Specify the path to the custom Dockerfile
"build": {
"dockerfile": "Dockerfile"
},
// Use the non-root user created in the Dockerfile
"remoteUser": "vscode",
// Set the workspace folder inside the container
"workspaceFolder": "/workspaces/fluent-plugin-datadog",
// Command to run after the container is created and the workspace is mounted.
// This installs the gem dependencies using Bundler.
"postCreateCommand": "bundle install && sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\"",
// Forward ports that might be useful (e.g., for testing Fluentd)
// Fluentd's default forward port is 24224. The repo's docker-compose also uses this.
"forwardPorts": [
24224
],
// Configuration specific to VS Code
"customizations": {
"vscode": {
"settings": {
// Optional: Configure Ruby environment settings if needed
"ruby.useBundler": true,
"ruby.lint": {
"rubocop": true
},
"ruby.format": "rubocop",
// Add other Ruby or general settings here
// Configure VS Code's integrated terminal to use Zsh
"terminal.integrated.defaultProfile.linux": "zsh (2)",
"terminal.integrated.profiles.linux": {
"zsh (2)": {
"path": "zsh"
}
}
},
// Specify VS Code extensions to install automatically
"extensions": [
"rebornix.ruby", // Official Ruby extension
"bungcip.better-toml", // For TOML config files
"kaiinui.vscode-ruby-test-explorer", // If you want a test explorer UI
"dbaeumer.vscode-eslint", // If there are JS parts or linting
"redhat.vscode-yaml", // For YAML files (like the docker-compose)
"ms-azuretools.vscode-docker" // Useful for working with Docker inside VS Code
// Add any other extensions relevant to your workflow
]
}
}
// Uncomment to connect as root instead of the remoteUser.
// "remoteUser": "root"
}
11 changes: 9 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true
ruby-version: ${{ matrix.ruby-version }}

- name: Configure Bundler to exclude development gems
run: bundle config set --local without development

- name: Install dependencies
run: bundle install --jobs 4 --retry 3

- name: Run tests
run: bundle exec rake
36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Fluentd with Plugin",
"type": "Ruby",
"request": "launch",
"program": "/usr/local/bin/bundle",
"args": [
"exec",
"fluentd",
"-c",
"${workspaceFolder}/test/fluentd-test.conf",
"-p",
"${workspaceFolder}/lib/fluent/plugin"
],
"cwd": "${workspaceFolder}",
"showDebuggerOutput": true,
"useBundler": true
},
{
"name": "Debug Rake Tests",
"type": "Ruby",
"request": "launch",
"program": "/usr/local/bin/bundle",
"args": [
"exec",
"rake",
"test"
],
"cwd": "${workspaceFolder}",
"showDebuggerOutput": true,
"useBundler": true
}
]
}
54 changes: 54 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Install Dependencies",
"type": "shell",
"command": "bundle install",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Build Gem",
"type": "shell",
"command": "gem build fluent-plugin-datadog.gemspec",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": [],
"dependsOn": ["Install Dependencies"]
},
{
"label": "Run Tests",
"type": "shell",
"command": "bundle exec rake test",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Build and Test",
"dependsOn": [
"Install Dependencies",
"Build Gem",
"Run Tests"
],
"group": {
"kind": "build",
"isDefault": false
}
}
]
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,11 @@ To build a new version of this plugin and push it to RubyGems:

`curl -u <USERNAME> https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials`, it will ask for your password.

## Development Environment

This repository includes the files to run it in a dev container in VS Code. To use it:

1. Install VS Code and Docker.
2. Open the project in VS Code with the Dev Containers extension.

VS Code will build and start the container automatically.
8 changes: 5 additions & 3 deletions fluent-plugin-datadog.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency "fluentd", [">= 1", "< 2"]
spec.add_runtime_dependency "net-http-persistent", '~> 4.0.1'
spec.add_runtime_dependency "rake", "~> 12.0"
spec.add_runtime_dependency "test-unit", "~> 3.1"
spec.add_runtime_dependency "webmock", "~> 3.6.0"

spec.add_development_dependency "bundler", "~> 2.1"
spec.add_development_dependency "test-unit", '~> 3.1'
spec.add_development_dependency "rake", "~> 12.0"
spec.add_development_dependency "yajl-ruby", "~> 1.2"
spec.add_development_dependency 'webmock', "~> 3.6.0"
spec.add_development_dependency "ruby-debug-ide"
spec.add_development_dependency "debase"

spec.metadata = {
'bug_tracker_uri' => 'https://github.com/DataDog/fluent-plugin-datadog/issues',
Expand Down
Loading