Skip to content

Commit

Permalink
feat(packages): add tracepusher & har-to-otel
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelreyrol committed Jan 8, 2024
1 parent 3d0626d commit 36a2226
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

- [otel-collector-builder](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder) - Generates a custom OpenTelemetry Collector binary based on a given configuration
- [tracetest](https://github.com/kubeshop/tracetest) - Build integration and end-to-end tests in minutes using OpenTelemetry and trace-based testing
- [tracepusher](https://github.com/agardnerIT/tracepusher) - Generate and push OpenTelemetry Trace data to an OTEL collector in JSON format
- [har-to-otel](https://github.com/agardnerIT/tracepusher/tree/main/har-to-otel) - Chrome DevTools HAR file to OpenTelemetry converter

## Library

Expand Down
2 changes: 2 additions & 0 deletions src/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ prev:
otel-collector-builder = prev.callPackage ./otel-collector-builder.nix { };
# Remove when merged: https://github.com/NixOS/nixpkgs/pull/275406
tracetest = prev.callPackage ./tracetest.nix { };
tracepusher = prev.callPackage ./tracepusher { };
har-to-otel = prev.callPackage ./har-to-otel { };
}
48 changes: 48 additions & 0 deletions src/packages/har-to-otel/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{ lib
, python3
, python3Packages
, fetchFromGitHub
, substituteAll
}:

python3Packages.buildPythonApplication rec {
pname = "har-to-otel";
version = "0.9.0";
format = "setuptools";

disabled = python3.pythonOlder "3.11";

src = fetchFromGitHub {
owner = "agardnerIT";
repo = "tracepusher";
rev = "668053739ee93556f6a121bf0f047514379c4596";
hash = "sha256-w+xrp2uHoXZQv4YzM1Kmiv2KSlM0iHh1n8OlgUcq0OQ=";
};

patches = [ ./shebang.patch ];

postPatch = let
setup = substituteAll {
src = ./setup.py;
desc = meta.description;
inherit pname version;
};
in ''
ln -s ${setup} setup.py
'';

propagatedBuildInputs = [
python3Packages.requests
];

doCheck = false;

meta = with lib; {
changelog = "https://github.com/agardnerIT/tracepusher/releases/tag/${version}";
description = "Chrome DevTools HAR File to OpenTelemetry Converter";
homepage = "https://github.com/agardnerIT/tracepusher/tree/main/har-to-otel";
license = licenses.asl20;
maintainers = with maintainers; [ gaelreyrol ];
mainProgrom = "har-to-otel.py";
};
}
20 changes: 20 additions & 0 deletions src/packages/har-to-otel/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python

import codecs
import os
from setuptools import setup, find_packages

def open_local(paths, mode="r", encoding="utf8"):
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths)
return codecs.open(path, mode, encoding)

with open_local(["requirements.txt"]) as req:
install_requires = req.read().split("\n")

setup(name='@pname@',
version='@version@',
description='@desc@',
scripts=["har-to-otel/har-to-otel.py"],
packages=find_packages(),
install_requires=install_requires,
)
10 changes: 10 additions & 0 deletions src/packages/har-to-otel/shebang.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/har-to-otel/har-to-otel.py b/har-to-otel/har-to-otel.py
index 135350e..658e6e5 100644
--- a/har-to-otel/har-to-otel.py
+++ b/har-to-otel/har-to-otel.py
@@ -1,3 +1,5 @@
+#! /usr/bin/env python
+
import json
import math
import subprocess
48 changes: 48 additions & 0 deletions src/packages/tracepusher/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{ lib
, python3
, python3Packages
, fetchFromGitHub
, substituteAll
}:

python3Packages.buildPythonApplication rec {
pname = "tracepusher";
version = "0.9.0";
format = "setuptools";

disabled = python3.pythonOlder "3.11";

src = fetchFromGitHub {
owner = "agardnerIT";
repo = "tracepusher";
rev = version;
hash = "sha256-OtdIIw6DxyTHZusuP3oJxxXJ4Ic0zoYQa805jHvh9oo=";
};

patches = [ ./shebang.patch ];

postPatch = let
setup = substituteAll {
src = ./setup.py;
desc = meta.description;
inherit pname version;
};
in ''
ln -s ${setup} setup.py
'';

propagatedBuildInputs = [
python3Packages.requests
];

doCheck = false;

meta = with lib; {
changelog = "https://github.com/agardnerIT/tracepusher/releases/tag/${version}";
description = "Generate and push OpenTelemetry Trace data to an OTEL collector in JSON format";
homepage = "https://github.com/agardnerIT/tracepusher";
license = licenses.asl20;
maintainers = with maintainers; [ gaelreyrol ];
mainProgram = "tracepusher";
};
}
20 changes: 20 additions & 0 deletions src/packages/tracepusher/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python

import codecs
import os
from setuptools import setup, find_packages

def open_local(paths, mode="r", encoding="utf8"):
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths)
return codecs.open(path, mode, encoding)

with open_local(["requirements.txt"]) as req:
install_requires = req.read().split("\n")

setup(name='@pname@',
version='@version@',
description='@desc@',
scripts=["tracepusher.py"],
packages=find_packages(),
install_requires=install_requires,
)
10 changes: 10 additions & 0 deletions src/packages/tracepusher/shebang.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/tracepusher.py b/tracepusher.py
index c23c526..e0490b4 100644
--- a/tracepusher.py
+++ b/tracepusher.py
@@ -1,3 +1,5 @@
+#! /usr/bin/env python
+
import sys
import requests
import time

0 comments on commit 36a2226

Please sign in to comment.