id int64 0 1.29M | original_id stringlengths 32 32 | swhid stringlengths 100 170 | sha1 stringlengths 40 40 | repo_name stringlengths 2 45 | repo_group stringclasses 12
values | filepath stringlengths 5 153 | name stringlengths 1 14.9k | type stringclasses 3
values | code stringlengths 7 2.12M |
|---|---|---|---|---|---|---|---|---|---|
1,900 | d11dc0e7fc25a98e2063abb39c6a5bf2 | swh:1:cnt:358f1ca82d270de66df45b4db08ea47f1a880c77;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=25-90/ | f96210234bcd103deca3cc8c5ea6dcafaa5dbb85 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_events.py | process_revisions(spark, source_table, target_table, year, month, day, hour, big_wikis=None) | function | def process_revisions(spark, source_table, target_table, year, month, day, hour, big_wikis=None) -> None:
# pushdown the earliest touched revision_dt per wiki. example:
# ...
# OR
# (t.wiki_id = 'enwiki' AND t.revision_dt >= '2001-01-23T05:20:49')
# OR
# ...
sql_earliest_revision_dt_per_wik... |
1,901 | 6c7d2b75bcfb70dffb1bea933d46d45b | swh:1:cnt:358f1ca82d270de66df45b4db08ea47f1a880c77;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=329-388/ | f96210234bcd103deca3cc8c5ea6dcafaa5dbb85 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_events.py | process_page_moves(spark, source_table, target_table, year, month, day, hour, big_wikis=None) | function | def process_page_moves(spark, source_table, target_table, year, month, day, hour, big_wikis=None) -> None:
sql_page_ids_per_wiki = \
f"""
SELECT wiki_id,
sort_array(collect_set(page_id)) as page_ids
FROM (
SELECT
wiki_id,
page.page_id
FROM {source_table}
WHERE year={year}... |
1,902 | 54e774b87b903f1f27f99a7219d43ec0 | swh:1:cnt:358f1ca82d270de66df45b4db08ea47f1a880c77;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=7-22/ | f96210234bcd103deca3cc8c5ea6dcafaa5dbb85 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_events.py | parse_args(args) | function | def parse_args(args) -> argparse.Namespace: # pragma: no cover
parser = argparse.ArgumentParser(
description='Run various SQL DML from an event source table to an Iceberg sink table.'
)
parser.add_argument('--source_table', help='table we intend to read from')
parser.add_argument('--target_tabl... |
1,903 | 50d65f9282e2cb7b71c91df5d5a8ba64 | swh:1:cnt:358f1ca82d270de66df45b4db08ea47f1a880c77;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=92-244/ | f96210234bcd103deca3cc8c5ea6dcafaa5dbb85 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_events.py | run_merge_into(spark, source_table, target_table, year, month, day, hour, source_predicate, optimization_predicates) | function | def run_merge_into(spark, source_table, target_table, year, month, day, hour, source_predicate, optimization_predicates):
sql_merge_into = \
f"""
WITH deduplicated_mediawiki_page_content_change AS (
-- we want to ingest the latest state of a (wiki_id, rev_id) pair
-- so below we pick latest event ba... |
1,904 | 3fb60c57f6a860036f517d269948988c | swh:1:cnt:358f1ca82d270de66df45b4db08ea47f1a880c77;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=309-326/ | f96210234bcd103deca3cc8c5ea6dcafaa5dbb85 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_events.py | run_delete(spark, target_table, delete_predicates) | function | def run_delete(spark, target_table, delete_predicates):
sql_delete = \
f"""
DELETE
FROM {target_table} t
WHERE (
-- pushdown wiki_ids and page_ids that are changing
-- to limit how much data we effectively read. See T369868#10142190.
{delete_predicates}
)
"""
print("Now doing DELETE via:")
... |
1,905 | 46a6fc937be8a2c034f8d69c4cf1b6aa | swh:1:cnt:358f1ca82d270de66df45b4db08ea47f1a880c77;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=390-457/ | f96210234bcd103deca3cc8c5ea6dcafaa5dbb85 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_events.py | run_move_merge_into(spark, source_table, target_table, year, month, day, hour, optimization_predicates) | function | def run_move_merge_into(spark, source_table, target_table, year, month, day, hour, optimization_predicates):
sql_merge_into = \
f"""
-- pick latest move event for a (wiki_id, page_id) tuple
WITH deduplicated_mediawiki_page_moves AS (
SELECT * FROM (
SELECT
*,
row_number() ove... |
1,906 | 3eb08b20d7a76c643000d03b8cb5e936 | swh:1:cnt:358f1ca82d270de66df45b4db08ea47f1a880c77;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=460-501/ | f96210234bcd103deca3cc8c5ea6dcafaa5dbb85 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_events.py | main() | function | def main() -> None: # pragma: no cover
args = parse_args(sys.argv[1:])
spark = SparkSession.builder.getOrCreate()
if 'revisions' in args.event_categories:
process_revisions(
spark,
args.source_table,
args.target_table,
args.year,
args.mo... |
1,907 | 884ac1746b2360ae082bb00277165a59 | swh:1:cnt:c1d02a7756e19389fe845984572336acd7d13520;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=7-18/ | 2070c93ad232b3c1730c20eab2416c0dfe5ae728 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_visibility_events.py | parse_args(args) | function | def parse_args(args) -> argparse.Namespace: # pragma: no cover
parser = argparse.ArgumentParser(
description='Run a MERGE INTO from a visibility event source table to an Iceberg sink table.'
)
parser.add_argument('--source_table', help='table we intend to read from')
parser.add_argument('--targ... |
1,908 | d0b768b39e13b17e44534d19e6b7697e | swh:1:cnt:c1d02a7756e19389fe845984572336acd7d13520;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=21-108/ | 2070c93ad232b3c1730c20eab2416c0dfe5ae728 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_visibility_events.py | process_visibility_events(spark, source_table, target_table, year, month, day, hour) | function | def process_visibility_events(spark, source_table, target_table, year, month, day, hour) -> None:
sql_rev_ids_per_page_ids_per_wiki = \
f"""
SELECT
database,
page_id,
sort_array(collect_set(rev_id)) as rev_ids
FROM {source_table}
WHERE year = {year}
AND month = {month}
AND day = {day}
{f"AND ho... |
1,909 | 1b9cc1f760a78126f29e3fc88e4a60b9 | swh:1:cnt:c1d02a7756e19389fe845984572336acd7d13520;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=111-126/ | 2070c93ad232b3c1730c20eab2416c0dfe5ae728 | mediawiki-content-pipelines | analytics | mediawiki_content_pipelines/revision_history/process_visibility_events.py | main() | function | def main() -> None: # pragma: no cover
args = parse_args(sys.argv[1:])
spark = SparkSession.builder.getOrCreate()
process_visibility_events(
spark,
args.source_table,
args.target_table,
args.year,
args.month,
args.day,
args.hour
)
spark.sto... |
1,910 | a319e6052d05850134b7d27072743959 | swh:1:cnt:cce4dc8ddd946faf9fb9b60efdb06b51a46202d6;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=4-27/ | b722247c511424202546b45002fd910c2e8bf1b3 | mediawiki-content-pipelines | analytics | tests/content_current/test_content_current_process_changes.py | test_parse_args() | function | def test_parse_args():
# Usage: process_changes.py --source_table source.table
# --target_table target.table
# --join_strategy BROADCAST
# Test with valid args:
args0 = ['--source_table', 'source.table',
'--target_table', 'target.t... |
1,911 | 70a1d95f9a116ea2f5e8becd8d4dd571 | swh:1:cnt:3bc00c3ce1305633f4211e29740b55e96c068fd0;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=9-89/ | 04c1d8014e3adb0a8cea4483594eac64333f1af2 | mediawiki-content-pipelines | analytics | tests/content_history/test_compute_completeness_slo_daily.py | test_parse_args() | function | def test_parse_args():
# Usage: compute_completeness_slo_daily.py
# --source_mw_content_history_table source.mw_content_history
# --source_mw_event_page_change_table source.event_page_change
# --source_mw_revision_visibility_change_table source.revision_visibility_change
# --source_mw_incons... |
1,912 | 4190e1762ac9e7038820b0b7ab409dc6 | swh:1:cnt:96de2b1da0aca23fdca7767ed9e7e174a5ae7210;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=9-75/ | c0e0dc1ccfd1351f4d0fbed1f0031de8a05d87f5 | mediawiki-content-pipelines | analytics | tests/content_history/test_compute_completeness_slo_monthly.py | test_parse_args() | function | def test_parse_args():
# Usage: compute_completeness_slo_monthly.py
# --source_mw_content_history_table source.mw_content_history
# --source_mw_event_page_change_table source.event_page_change
# --source_mw_revision_visibility_change_table source.revision_visibility_change
# --source_mw_inco... |
1,913 | 155bb120a81d8cc38b2a00f1d6d028a5 | swh:1:cnt:5fd19fde875f87dedaf85230bc4a27a19757a5b5;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=7-36/ | 8354af4d315ca6b8281b387627c2245d286badd8 | mediawiki-content-pipelines | analytics | tests/content_history/test_content_history_consistency_check.py | test_parse_args() | function | def test_parse_args():
# Usage: consistency_check.py --wiki_id enwiki
# --target_table wmf_dumps.wikitext_raw_rc2
# --results_table wmf_dumps.wikitext_mismatch_rows_rc1
# --min_timestamp 2024-01-01TOO:OO:OO
# ... |
1,914 | 0c9ec5e87346fac9e4f012cef88e7931 | swh:1:cnt:5fd19fde875f87dedaf85230bc4a27a19757a5b5;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=39-47/ | 8354af4d315ca6b8281b387627c2245d286badd8 | mediawiki-content-pipelines | analytics | tests/content_history/test_content_history_consistency_check.py | test_blank_rev_timestamps_can_be_caught() | function | def test_blank_rev_timestamps_can_be_caught():
mw_iso = "%Y%m%d%H%M%S"
# assert we can catch bad rev_timestamps, which are 14 spaces, via ValueError
with pytest.raises(ValueError):
datetime.strptime(' ', mw_iso)
# our default timestamp works
assert datetime.strptime('200001010... |
1,915 | f79f28f7fa33b6d6c1d3c85488e67aec | swh:1:cnt:0e7a2a95b1abc93e07fa570dbccf1f2a2ea6e25d;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=7-21/ | e6ab64f5dc78903e696cf77d271563f01b4763b4 | mediawiki-content-pipelines | analytics | tests/content_history/test_content_history_copy_localuser_table_from_mariadb_to_datalake.py | test_parse_args() | function | def test_parse_args():
# Usage: copy_localuser_table_from_mariadb_to_datalake.py --localuser_target_table tmp.mediawiki_centralauth_localuser_2025_01_01
# --read_partitions 256
# --mariadb_user... |
1,916 | 154677050ac477b765f71cf4d65535d6 | swh:1:cnt:1c11199d212601cb54e3abdb333542ad2634ae37;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=4-52/ | 127140e4eaf218698ba968f923188799d42f78ab | mediawiki-content-pipelines | analytics | tests/content_history/test_content_history_emit_reconcile_events_to_kafka.py | test_parse_args() | function | def test_parse_args():
# Usage: emit_reconcile_events_to_kafka.py
# --wiki_id enwiki
# --inconsistent_rows_table wmf_dumps.wikitext_mismatch_rows_rc1
# --wikis_table canonical_data.wikis
# ... |
1,917 | e88e438bf2de8b8ce3c44d9558158782 | swh:1:cnt:fe9e873329cfff7a3fe16b409f525f7c94704b9c;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=4-63/ | 8c8523f5ef5b522f7a66b4a1a537618c0bb7a0e8 | mediawiki-content-pipelines | analytics | tests/content_history/test_content_history_process_events.py | test_parse_args() | function | def test_parse_args():
# Test with hour:
# Usage: process_events.py --source_table source.table
# --target_table target.table
# --year 2023
# --month 2
# --day 15
# ... |
1,918 | 799d9df10d237a007d1fa7b1dd6fe867 | swh:1:cnt:592cb07cea289b01f6ee06fed8c824bedca84d22;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=4-45/ | 56f169fac0136d4658df6d319916e80139c152b3 | mediawiki-content-pipelines | analytics | tests/content_history/test_content_history_process_visibility_events.py | test_parse_args() | function | def test_parse_args():
# Test with hour:
# Usage: process_visibility_events.py --source_table source.table
# --target_table target.table
# --year 2023
# --month 2
# ... |
1,919 | b930a9c9d1a18201d45a901eb65f311f | swh:1:cnt:b582e3ac438bfa14b73fdb2903cfade58b42f865;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=8-15/ | 8c40e6e156815eab103840c18896651d52ca2f1e | mediawiki-content-pipelines | analytics | tests/integration_tests/conftest.py | spark() | function | def spark():
# set timezone to UTC globally.
os.environ['TZ'] = 'UTC'
time.tzset()
# set spark's timezone to UTC as well
spark_session = SparkSession.builder.config("spark.sql.session.timeZone", "UTC").getOrCreate()
yield spark_session
spark_session.stop() |
1,920 | e88e438bf2de8b8ce3c44d9558158782 | swh:1:cnt:54167515469c2bbdc40b6087d7f170a008183fcc;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=4-63/ | 2b0eebce4adc58246545c89a058b0cd3568bde9c | mediawiki-content-pipelines | analytics | tests/revision_history/test_revision_history_process_events.py | test_parse_args() | function | def test_parse_args():
# Test with hour:
# Usage: process_events.py --source_table source.table
# --target_table target.table
# --year 2023
# --month 2
# --day 15
# ... |
1,921 | 799d9df10d237a007d1fa7b1dd6fe867 | swh:1:cnt:a4bf50fda3990c9af1828d7b599398e15f04c716;origin=https://gitlab.wikimedia.org/repos/data-engineering/mediawiki-content-pipelines.git;lines=4-45/ | 2959639e9c066284e8bf065db8136d988c1a2e63 | mediawiki-content-pipelines | analytics | tests/revision_history/test_revision_history_process_visibility_events.py | test_parse_args() | function | def test_parse_args():
# Test with hour:
# Usage: process_visibility_events.py --source_table source.table
# --target_table target.table
# --year 2023
# --month 2
# ... |
1,922 | 909012b5f366d30a349ea9fff201bba7 | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=57-62/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | _Config | type | interface _Config {
service_name?: string;
logging?: WinstonLoggerOptions;
metrics?: PrometheusMetricsConfig;
[key: string]: any;
} |
1,923 | b164be5aef21dbb4344f8bf51d270fda | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=67-175/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | ServiceUtils | type | class ServiceUtils<T extends Record<string, any> = object> {
config: Config<T>;
logger: winston.Logger;
metrics: Metrics;
prometheusServer?: PrometheusServer;
/**
* Creates the logger, metrics, and prometheus metrics endpoint
*
* @param config
*/
constructor( config: Config<T> ) {
this.config = conf... |
1,924 | dfa8bfa44be7725c87d95c1d6daaeec3 | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=64-65/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | Config | type | // Allow generic typing of arbitrary key/values
type Config<T extends Record<string, any>> = _Config & T; |
1,925 | 8762a8314fffc614f68a78804645bcd3 | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=76-97/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | ServiceUtils::constructor | function | /**
* Creates the logger, metrics, and prometheus metrics endpoint
*
* @param config
*/
constructor( config: Config<T> ) {
this.config = config;
this.logger = ServiceUtils.createLogger( config );
// Backwards compatibility for array of metrics config
if ( config.metrics instanceof Array ) {
config.... |
1,926 | 7911f78c5c3fa7a187b1df0c5c582aac | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=110-116/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | ServiceUtils::createMetrics | function | static createMetrics( config: Config<Record<string, any>>, logger: winston.Logger ) {
return new Metrics(
config.service_name ?? 'default_service',
logger,
config.metrics,
);
} |
1,927 | fc85833c99d301ba4a6fbcddcbf17f84 | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=103-108/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | ServiceUtils::createLogger | function | static createLogger( config: Config<Record<string, any>> ) {
return createWinstonLogger(
config.service_name ?? 'default_service',
config.logging as WinstonLoggerOptions,
);
} |
1,928 | a0151486638f506c6fbca3abea1f92b0 | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=99-101/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | ServiceUtils::createPrometheusServer | function | static createPrometheusServer( prometheus_config: PrometheusMetricsConfig, defaultLabels: Record<string, string> ) {
return new PrometheusServer( prometheus_config, defaultLabels );
} |
1,929 | 9b093509554f6c685579bb8b86b75d8f | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=118-122/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | ServiceUtils::teardown | function | async teardown() {
if ( this.prometheusServer ) {
await this.prometheusServer.close();
}
} |
1,930 | d583ca42db7d9fb0cd4df1a975cd2183 | swh:1:cnt:4c0cedd8a1e79101bb6e08bcbedd7c574237c8a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=124-174/ | e0b024ce181e1e6b47ba9e04ae9d5d05364cb795 | service-utils | analytics | src/index.ts | ServiceUtils::loadConfig | function | /**
* @param {Object=} options c12 loadConfig configuration
* @param {Object=} options.defaultConfig Default config overrideable from yaml
* @param {string=} options.envName Environment-conditional to load
* @param {string=} options.configDirectory Default config directory overrideable in cli. Overrides c12's o... |
1,931 | 048ed71b110f843503670e0a5a941681 | swh:1:cnt:3b0e2a3efbb74b5294453037a43da9683e153ebf;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=14-66/ | b3c12e878a941953543f8bf21ca7daf66a66ee8b | service-utils | analytics | src/open_telemetry.ts | XRequestPropagator | type | class XRequestPropagator implements TextMapPropagator {
/**
* Injects values from a given `Context` into a carrier.
*
* OpenTelemetry defines a common set of format values (TextMapPropagator),
* and each has an expected `carrier` type.
*
* @param {Context} context the Context from which to extract values ... |
1,932 | fbe62aeb19a7feea8fe03567093b6ffe | swh:1:cnt:3b0e2a3efbb74b5294453037a43da9683e153ebf;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=16-35/ | b3c12e878a941953543f8bf21ca7daf66a66ee8b | service-utils | analytics | src/open_telemetry.ts | XRequestPropagator::inject | function | /**
* Injects values from a given `Context` into a carrier.
*
* OpenTelemetry defines a common set of format values (TextMapPropagator),
* and each has an expected `carrier` type.
*
* @param {Context} context the Context from which to extract values to transmit over
* the wire.
* @param {unknown} ca... |
1,933 | 3626a6da74c5eac96cc7944f0761c752 | swh:1:cnt:3b0e2a3efbb74b5294453037a43da9683e153ebf;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=63-65/ | b3c12e878a941953543f8bf21ca7daf66a66ee8b | service-utils | analytics | src/open_telemetry.ts | XRequestPropagator::fields | function | fields(): string[] {
return [ X_REQUEST_HEADER ];
} |
1,934 | db13b00a74933cea4ef1d499c5f46fcd | swh:1:cnt:3b0e2a3efbb74b5294453037a43da9683e153ebf;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=37-61/ | b3c12e878a941953543f8bf21ca7daf66a66ee8b | service-utils | analytics | src/open_telemetry.ts | XRequestPropagator::extract | function | /**
* Given a `Context` and a carrier, extract context values from a
* carrier and return a new context, created from the old context, with the
* extracted values.
*
* @param {Context} context the Context from which to extract values to transmit over
* the wire.
* @param {unknown} carrier the carrier ... |
1,935 | 12ffcdbcce82b016089d52373be83b6a | swh:1:cnt:4081dca4874fa9c485e119c1d2d3f41a65e88f68;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=20-20/ | 0c1aaf60124b46d4b4ec3abf633dfe7d91f500be | service-utils | analytics | src/logging/index.ts | Level | type | type Level = keyof typeof logLevels; |
1,936 | 4d2ebf6b1e9523637ec99116cf58a259 | swh:1:cnt:4081dca4874fa9c485e119c1d2d3f41a65e88f68;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=26-39/ | 0c1aaf60124b46d4b4ec3abf633dfe7d91f500be | service-utils | analytics | src/logging/index.ts | WinstonLoggerOptions | type | interface WinstonLoggerOptions {
level?: Level;
stacktrace?: boolean;
format?: keyof typeof winston.format | 'ecs';
formatOptions?: any;
transports?: {
transport: 'File' | 'Console' | 'Http' | 'Stream';
options?: {
format?: keyof typeof winston.format | 'ecs';
[key: string]: any;
};
}[];
defaultMeta?... |
1,937 | 976431d1b009627eb3449e98d708a9f9 | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=7-21/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | Http | type | // (incomplete) ECS fragments derived from https://docs.wikimedia.org/ecs
// Only the keys used in the code are listed here.
interface Http {
request?: {
body?: {
content?: unknown;
};
id?: string;
[key: string]: unknown;
};
response?: {
[key: string]: unknown;
};
[key: string]: unknown;
} |
1,938 | fea72ab3b4b96f3b27157181a2fe859f | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=23-28/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | Url | type | interface Url {
full?: string;
path?: string;
query?: string;
[key: string]: unknown;
} |
1,939 | 95baf4e56bd213800f57bd93a283e2d4 | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=45-47/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | ResponseData | type | interface ResponseData {
[key: string]: unknown;
} |
1,940 | 432a50da56f0a25d40cc781356fe11a4 | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=30-34/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | Source | type | interface Source {
ip?: string;
port?: number;
[key: string]: unknown;
} |
1,941 | fce769eed8313e482af08534086fe186 | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=36-43/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | RequestData | type | interface RequestData {
remoteAddress?: string;
remotePort?: number;
url?: string;
path?: string;
params?: string[];
[key: string]: unknown;
} |
1,942 | 230c025c87fa4faffa002b9b5da5d559 | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=49-173/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | WikimediaEcsFormatMiddleware | type | /**
* A Winston `Format` for converting fields from the legacy bunyan structure
* that was passed into Winston's ecs formatter into the standard fields
* that Wikimedia uses.
* Must be inserted betwwen ecsFields() and ecsStringify().
*
* @class {Format}
* @param {Config} opts
*/
class WikimediaEcsFormatMiddlewa... |
1,943 | 07fdd913d6b93d62fc5f37e04d3621a2 | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=59-75/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | WikimediaEcsFormatMiddleware::transform | function | transform( info: TransformableInfo ): TransformableInfo {
// Process service name transformation
const serviceInfo = this.processServiceName( info );
// Process HTTP request/response data
const httpInfo = this.processHttpData( serviceInfo );
// Process request ID
const requestIdInfo = this.processRequestI... |
1,944 | 4c7554195bc60158ef235d0abeff4250 | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=149-172/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | WikimediaEcsFormatMiddleware::processRequestId | function | /**
* Handles request ID transformation
*
* @param info
*/
private processRequestId( info: TransformableInfo ): TransformableInfo {
if ( !info.requestId && !info.request_id ) {
return info;
}
const requestId = info.requestId ?? info.request_id;
const http = { request: { id: requestId } };
// Cre... |
1,945 | dada70164db442726fee5bb6153e0d8b | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=77-94/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | WikimediaEcsFormatMiddleware::processServiceName | function | /**
* Handles service name transformation from legacy bunyan structure
*
* @param info
*/
private processServiceName( info: TransformableInfo ): TransformableInfo {
if ( !info.serviceName && !( info.service && typeof info.service !== 'object' ) ) {
return info;
}
const serviceName = info.serviceName ... |
1,946 | 5931fae26da33f11e41058523a943739 | swh:1:cnt:39f3160253613a39fcf7fbff2ed86445ab9706fa;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=96-147/ | 96462dc3e4105c2bad76d3bc53cc541d121b8c74 | service-utils | analytics | src/logging/wikimedia_ecs.ts | WikimediaEcsFormatMiddleware::processHttpData | function | /**
* Processes HTTP request and response data into ECS format
* See https://github.com/wikimedia/service-template-node/blob/main/lib/util.js#L45
*
* @param info
*/
private processHttpData( info: TransformableInfo ): TransformableInfo {
if ( !info.request && !info.response ) {
return info;
}
const ... |
1,947 | 99e1d6e34844946bf636d9cce194a51f | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=7-7/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | MetricType | type | type MetricType = MetricTypeEnum | `${ MetricTypeEnum }`; |
1,948 | f2a51128e98e035c7104085ac42afbac | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=9-10/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | GenericPrometheusMetricsConfig | type | type GenericPrometheusMetricsConfig<T extends MetricType> =
ConstructorParameters<typeof Prometheus[T]>[0]; |
1,949 | 457c47fef606a4e4f1ab73e777e2d7d0 | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=12-17/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | RawMetricOptions | type | type RawMetricOptions<T extends MetricType> =
GenericPrometheusMetricsConfig<T>
& {
type: T;
[key: string]: any;
}; |
1,950 | 7524c0d684968e682c5810fa09534a0b | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=19-125/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | Metrics | type | class Metrics {
options: PrometheusMetricsConfig | undefined;
client: PrometheusClient;
prometheus: typeof Prometheus;
serviceName: string;
cache: Map<string, Metric>;
logger: Logger;
constructor(
serviceName: string,
logger: Logger,
options?: PrometheusMetricsConfig,
) {
this.options = options;
... |
1,951 | cfa30250eb4899384b192e5f5f62fe68 | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=32-51/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | Metrics::constructor | function | constructor(
serviceName: string,
logger: Logger,
options?: PrometheusMetricsConfig,
) {
this.options = options;
this.logger = logger;
this.cache = new Map();
this.serviceName = serviceName;
if ( !options || options && options.type === 'prometheus' ) {
this.client = new PrometheusClient(
this.lo... |
1,952 | bbbf69ed232208634b09c01637f5e3a9 | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=74-87/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | Metrics::makeMetric | function | /**
* @deprecated Use {@link createMetric} for new projects.
*
* @param options
* @return
*/
makeMetric( options: MetricOptions ) {
let metric = this.cache.get( options.name );
if ( metric === undefined ) {
metric = new Metric( this.client, this.logger, options );
this.cache.set( options.name, metr... |
1,953 | f7334deca0f1e3bf6acb65f2e0064aea | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=67-72/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | Metrics::fetchClient | function | /**
* @deprecated Remnant from service-runner. Use Prometheus directly.
*/
fetchClient() {
return this.client;
} |
1,954 | 256f8e9a48a2d47ad9d35372f2b936bc | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=53-55/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | Metrics::getServiceName | function | getServiceName() {
return this.serviceName;
} |
1,955 | f0dc32d63ba08f56d6110a84eb8196fb | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=57-65/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | Metrics::getServiceLabel | function | // T247820: Selectively disable service label based on environment variable.
// Intended for production use case where the service label will be set
// by the Prometheus server.
getServiceLabel() {
if ( process.env.METRICS_SERVICE_LABEL_ENABLED === 'false' ) {
return undefined;
}
return { service: this.serv... |
1,956 | c4faf9b031e82f0cc18f1d1294b049eb | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=89-120/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | Metrics::createMetric | function | /**
* Makes and returns a raw Prometheus Metric bypassing the service-runner wrapper.
*
* @param options
* @return
*/
createMetric<T extends MetricType>(
// Dynamically types the options to be the metrics options for Prometheus
options: RawMetricOptions<T>,
): InstanceType<typeof Prometheus[T]> {
cons... |
1,957 | 31bb57e1d76102696986238b4a1f376e | swh:1:cnt:6ca2aeda2e8f4c4bad5755d91911859c84ba6a62;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=122-124/ | 1a82172b8ab8abce429b8be70546868dfed2da82 | service-utils | analytics | src/metric/index.ts | Metrics::close | function | close() {
this.client.close();
} |
1,958 | c2d9e946e3d3faf9bc64d5e0a5ae32a9 | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=9-16/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | MetricTypeEnum | type | enum MetricTypeEnum {
GAUGE = 'Gauge',
HISTOGRAM = 'Histogram',
COUNTER = 'Counter',
SUMMARY = 'Summary',
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
TIMING = 'Histogram',
} |
1,959 | ce2d5739265e2b9f43e9d7d13925cfde | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=42-62/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | MetricOptions | type | interface MetricOptions {
type: MetricType;
/**
* Metrics are cached by this name, as opposed to makeRawMetrics
* where it's cached by the Prometheus metrics name
*/
name: string;
prometheus: {
name: string;
help: string;
staticLabels?: Record<string, string>;
buckets?: number[];
percentiles?: numbe... |
1,960 | f89e85a94dd1eb37aff3b10cabeed754 | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=69-160/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric | type | class Metric {
type: MetricType;
metric: PrometheusMetric;
logger: Logger;
constructor(
client: PrometheusClient,
logger: Logger,
options: MetricOptions,
) {
this.type = options.type;
this.logger = logger;
this.metric = client.makeMetric( options );
}
increment( amount = 1, labels: string[] = [] ... |
1,961 | 66f502cd26e75b4f735a7294ccfda2a3 | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=76-84/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric::constructor | function | constructor(
client: PrometheusClient,
logger: Logger,
options: MetricOptions,
) {
this.type = options.type;
this.logger = logger;
this.metric = client.makeMetric( options );
} |
1,962 | 7d6c8d4739d83df4a8c6fde96cb84032 | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=118-127/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric::gauge | function | gauge( amount: number, labels: string[] = [] ) {
if ( this.type === MetricTypeEnum.GAUGE ) {
this.metric.gauge( amount, labels );
} else {
this.logger.error(
`set() or unique() unsupported for metric type ${ this.type }`,
{ levelPath: 'error/metrics' },
);
}
} |
1,963 | a94491e38214a1cb9ab76be14db09894 | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=97-106/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric::decrement | function | decrement( amount = 1, labels: string[] = [] ) {
if ( this.type === MetricTypeEnum.GAUGE ) {
this.metric.decrement( amount, labels );
} else {
this.logger.error(
`decrement() unsupported for metric type ${ this.type }`,
{ levelPath: 'error/metrics' },
);
}
} |
1,964 | efa2fa06635157c7a5e9c7755c8073ae | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=108-116/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric::observe | function | observe( value: number, labels: string[] = [] ) {
if ( [ MetricTypeEnum.HISTOGRAM, MetricTypeEnum.SUMMARY ].includes( this.type as MetricTypeEnum ) ) {
this.metric.observe( value, labels );
} else {
this.logger.error( `observe() unsupported for metric type ${ this.type }`, {
levelPath: 'error/metrics',
... |
1,965 | 4a8488626e14d3543c54d87156850ff2 | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=86-95/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric::increment | function | increment( amount = 1, labels: string[] = [] ) {
if ( [ MetricTypeEnum.COUNTER, MetricTypeEnum.GAUGE ].includes( this.type as MetricTypeEnum ) ) {
this.metric.increment( amount, labels );
} else {
this.logger.error(
`increment() unsupported for metric type ${ this.type }`,
{ levelPath: 'error/metrics'... |
1,966 | a070b4a1e0ad8b51e471c783af0cf46f | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=129-138/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric::set | function | set( value: number, labels: string[] = [] ) {
if ( this.type === MetricTypeEnum.GAUGE ) {
this.metric.set( value, labels );
} else {
this.logger.error(
`set() or unique() unsupported for metric type ${ this.type }`,
{ levelPath: 'error/metrics' },
);
}
} |
1,967 | 569228d12258fb26649347eb651363e1 | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=140-148/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric::timing | function | timing( value: number, labels: string[] = [] ) {
if ( this.type === MetricTypeEnum.TIMING ) {
this.metric.timing( value, labels );
} else {
this.logger.error( `timing() unsupported for metric type ${ this.type }`, {
levelPath: 'error/metrics',
} );
}
} |
1,968 | a095ef11c2f04fc4e347f71bda707c98 | swh:1:cnt:984b87bc4a7f877e0ab7fb7148a3c33bd1f7056d;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=150-159/ | 30c0c749eaf7087d32672bdf09c258b012c738e8 | service-utils | analytics | src/metric/metric.ts | Metric::endTiming | function | endTiming( startTime: number, labels: string[] = [] ) {
if ( this.type === MetricTypeEnum.TIMING ) {
this.metric.endTiming( startTime, labels );
} else {
this.logger.error(
`endTiming() unsupported for metric type ${ this.type }`,
{ levelPath: 'error/metrics' },
);
}
} |
1,969 | d28bd27e138dc824e8cd9800b7b1fba9 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=23-125/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric | type | class PrometheusMetric {
options: MetricOptions;
client: typeof Prometheus;
staticLabels: any;
metric: Prometheus.Metric;
constructor( options: MetricOptions, client: typeof Prometheus ) {
this.client = client;
this.options = structuredClone( options );
if ( this.options.labels === undefined ) {
this.... |
1,970 | 45ff53c3ef7a575b5397342f4f8ff07c | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=130-145/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusClient | type | class PrometheusClient {
logger: Logger;
client: typeof Prometheus;
constructor( logger: Logger ) {
this.logger = logger;
this.client = Prometheus;
}
makeMetric( options: MetricOptions ) {
return new PrometheusMetric( options, this.client );
}
close() {}
} |
1,971 | 29e5b03821d95f495742b3a8aaaf2ac5 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=32-57/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::constructor | function | constructor( options: MetricOptions, client: typeof Prometheus ) {
this.client = client;
this.options = structuredClone( options );
if ( this.options.labels === undefined ) {
this.options.labels = { names: [] };
}
this.staticLabels = this.options.prometheus.staticLabels || {};
// Add staticLabel names t... |
1,972 | 353a341123530efdfc1b7bef90c8827a | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=78-82/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::increment | function | increment( amount: number, labelValues: string[] ) {
const updatedLabelValues = this._getLabelValues( labelValues );
// @ts-ignore
this.metric.labels.apply( this.metric, updatedLabelValues ).inc( amount );
} |
1,973 | 0667db1afa6a1d678566931b257bef40 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=84-88/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::decrement | function | decrement( amount: number, labelValues: string[] ) {
const updatedLabelValues = this._getLabelValues( labelValues );
// @ts-ignore
this.metric.labels.apply( this.metric, updatedLabelValues ).dec( amount );
} |
1,974 | 63e7e05335d4833917f43aa691bea75d | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=90-94/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::observe | function | observe( value: number, labelValues: string[] ) {
const updatedLabelValues = this._getLabelValues( labelValues );
// @ts-ignore
this.metric.labels.apply( this.metric, updatedLabelValues ).observe( value );
} |
1,975 | e937aa3fde729eafbcbaa2b706cb227c | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=59-76/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::_getLabelValues | function | /**
* Gets label values array for this metric
* including both static and dynamic labels merged together.
*
* @param {Array} labelValues
* @return {Array}
*/
_getLabelValues( labelValues: string[] ) {
// make a clone of labelValues.
const updatedLabelValues = [ ...labelValues ];
// Add staticLabel va... |
1,976 | 9f48b9602c15380e297508b9dccf82de | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=96-108/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::gauge | function | gauge( amount: number, labelValues: string[] ) {
const updatedLabelValues = this._getLabelValues( labelValues );
if ( amount < 0 ) {
// @ts-ignore
this.metric.labels
.apply( this.metric, updatedLabelValues )
// @ts-ignore
.dec( Math.abs( amount ) );
} else {
// @ts-ignore
this.metric.labels... |
1,977 | 722009021365d0414ecd1a02b9cc7809 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=110-114/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::set | function | set( value: number, labelValues: string[] ) {
const updatedLabelValues = this._getLabelValues( labelValues );
// @ts-ignore
this.metric.labels.apply( this.metric, updatedLabelValues ).set( value );
} |
1,978 | 50d43adbf2301c175b86f9ec1e718ba8 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=116-119/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::timing | function | timing( value: number, labelValues: string[] ) {
const updatedLabelValues = this._getLabelValues( labelValues );
this.observe( value, updatedLabelValues );
} |
1,979 | 94f17c25063d2e95bff1c40a4c672bb0 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=121-124/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusMetric::endTiming | function | endTiming( startTime: number, labelValues: string[] ) {
const updatedLabelValues = this._getLabelValues( labelValues );
this.timing( ( Date.now() - startTime ) / 1000, updatedLabelValues );
} |
1,980 | df83866192affdeec7452edbf5eaecd7 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=135-138/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusClient::constructor | function | constructor( logger: Logger ) {
this.logger = logger;
this.client = Prometheus;
} |
1,981 | d735524cfa868b44e83e0f68d7152521 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=140-142/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusClient::makeMetric | function | makeMetric( options: MetricOptions ) {
return new PrometheusMetric( options, this.client );
} |
1,982 | d98e5b05a4471d6fc931988526bb5408 | swh:1:cnt:6b9f44fdda95fb4a663a488adb2d3bb233d1c860;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=144-144/ | 36c6132e97973bc2cf5fada9616b50ba3bf8f8b7 | service-utils | analytics | src/metric/prometheus.ts | PrometheusClient::close | function | close() {} |
1,983 | ac6778621f74c6793fdb3c90829c177d | swh:1:cnt:2a916ac80ff7ef07491039e29a5c19f69b50b5fb;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=5-10/ | 67bffb299ee8530e5d2d82ff7ed893ed2a30a2d2 | service-utils | analytics | src/metric/prometheus_server.ts | PrometheusMetricsConfig | type | interface PrometheusMetricsConfig {
type: 'prometheus'; // TODO: Remove. Prometheus is the only supported type.
port: number;
name?: string; // TODO: Remove. Unused, from service-runner.
collectDefaultMetrics?: boolean;
} |
1,984 | 476e0a508aeb41204746fbba07444024 | swh:1:cnt:2a916ac80ff7ef07491039e29a5c19f69b50b5fb;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=13-39/ | 67bffb299ee8530e5d2d82ff7ed893ed2a30a2d2 | service-utils | analytics | src/metric/prometheus_server.ts | PrometheusServer | type | class PrometheusServer {
config: PrometheusMetricsConfig;
server: HTTP.Server;
constructor( config: PrometheusMetricsConfig, defaultLabels: Record<string, string> = { service: 'default_service' } ) {
this.config = config;
if ( this.config.collectDefaultMetrics !== false ) {
Prometheus.collectDefaultMetrics(... |
1,985 | 933fd0658c42b199123863f9047b008d | swh:1:cnt:2a916ac80ff7ef07491039e29a5c19f69b50b5fb;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=18-27/ | 67bffb299ee8530e5d2d82ff7ed893ed2a30a2d2 | service-utils | analytics | src/metric/prometheus_server.ts | PrometheusServer::constructor | function | constructor( config: PrometheusMetricsConfig, defaultLabels: Record<string, string> = { service: 'default_service' } ) {
this.config = config;
if ( this.config.collectDefaultMetrics !== false ) {
Prometheus.collectDefaultMetrics();
}
Prometheus.register.setDefaultLabels( defaultLabels );
this.server = HTTP... |
1,986 | 95766407193fe25a3fa8c4f40f6d7a92 | swh:1:cnt:2a916ac80ff7ef07491039e29a5c19f69b50b5fb;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=33-38/ | 67bffb299ee8530e5d2d82ff7ed893ed2a30a2d2 | service-utils | analytics | src/metric/prometheus_server.ts | PrometheusServer::close | function | async close() {
Prometheus.register.clear();
this.server.close( ( err ) => {
Promise.resolve( err );
} );
} |
1,987 | cbc5bbc09fee18d09c46ef2d43133a49 | swh:1:cnt:2a916ac80ff7ef07491039e29a5c19f69b50b5fb;origin=https://gitlab.wikimedia.org/repos/data-engineering/service-utils.git;lines=29-31/ | 67bffb299ee8530e5d2d82ff7ed893ed2a30a2d2 | service-utils | analytics | src/metric/prometheus_server.ts | PrometheusServer::start | function | start() {
this.server.listen( this.config.port );
} |
1,988 | d38da5551a13c80f9e65bc9303fd4f08 | swh:1:cnt:7ab033163b4c7d722e927c7f30c043a42df4b980;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=26-36/ | 9b100a545ce2c71814d1fe5e1078de7c5bb7f5ac | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/TimestampedRecord.java | TimestampedRecord | type | @Getter
@EqualsAndHashCode
public class TimestampedRecord<P> {
private P payload;
private Optional<Long> timestamp;
public TimestampedRecord(P payload, Optional<Long> timestamp) {
this.payload = payload;
this.timestamp = timestamp;
}
} |
1,989 | bd42fd18cc6a85ae5df22504c514330b | swh:1:cnt:a5155f9bb11ce646c3d1763050565abc48c9661f;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=26-43/ | 5d50559649cfd225bd758d6db79fc4f456109752 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/compression/CompressionFactory.java | CompressionFactory | type | /**
* Duplication of {@link org.apache.gobblin.compression.CompressionFactory} to use
* a modified instance of GzipCodec generating '.gz' extensions instead of '.gzip'.
*/
public final class CompressionFactory {
public static StreamCodec buildStreamCompressor(Map<String, Object> properties) {
String type... |
1,990 | f021bbed18dd13ccccffad945dae8d5f | swh:1:cnt:a5155f9bb11ce646c3d1763050565abc48c9661f;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=31-38/ | 5d50559649cfd225bd758d6db79fc4f456109752 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/compression/CompressionFactory.java | CompressionFactory::buildStreamCompressor(Map<String, Object> properties) | function | public static StreamCodec buildStreamCompressor(Map<String, Object> properties) {
String type = CompressionConfigParser.getCompressionType(properties);
if (!GzipCodec.TAG.equals(type)) {
throw new IllegalArgumentException("Can't build compressor of type " + type);
}
return n... |
1,991 | 3566264803e6b8f2e6931b9a4b75dc8a | swh:1:cnt:e043fcf125d63eb7ce5bf6c726060d5299c1c4f7;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=23-36/ | 671b388e3d2ce23f732b025b1bc325ebc8e72ef7 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/compression/GzipCodec.java | GzipCodec | type | /**
* Gzip codec using a '.gz' extension instead of '.gzip'.
*/
@SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_SUPERCLASS")
public class GzipCodec extends org.apache.gobblin.codec.GzipCodec {
public static final String TAG = "gz";
@Override
public String getTag() {
return TAG;
}
} |
1,992 | 264a3c3a43a4bf41194f9855b96ec560 | swh:1:cnt:e043fcf125d63eb7ce5bf6c726060d5299c1c4f7;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=31-34/ | 671b388e3d2ce23f732b025b1bc325ebc8e72ef7 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/compression/GzipCodec.java | GzipCodec::getTag() | function | @Override
public String getTag() {
return TAG;
} |
1,993 | 67badee6dd7e2241efc2ea9befca3052 | swh:1:cnt:e66ac4b552876e2e4a3a9a7387cb607527302fbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=35-75/ | 489faa34e1b7f5f84574e22f753a3e2db9c77e05 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/converter/TimestampedRecordConverterWrapper.java | TimestampedRecordConverterWrapper | type | public class TimestampedRecordConverterWrapper<I, O>
extends Converter<String, String, TimestampedRecord<I>, TimestampedRecord<O>> {
public static final String CONVERTER_TIMESTAMPED_RECORD_WRAPPED = "converter.timestampedrecord.wrapped.class";
private Converter<String, String, I, O> wrappedConverter;
... |
1,994 | 3b7d2767ca71a33d0560107f0f95c063 | swh:1:cnt:e66ac4b552876e2e4a3a9a7387cb607527302fbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=42-58/ | 489faa34e1b7f5f84574e22f753a3e2db9c77e05 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/converter/TimestampedRecordConverterWrapper.java | TimestampedRecordConverterWrapper::init(WorkUnitState workUnit) | function | @Override
public Converter<String, String, TimestampedRecord<I>, TimestampedRecord<O>> init(WorkUnitState workUnit) {
String wrappedConverterClassKey = ForkOperatorUtils.getPropertyNameForBranch(workUnit, CONVERTER_TIMESTAMPED_RECORD_WRAPPED);
Preconditions.checkArgument(workUnit.contains(wrappedCo... |
1,995 | 0d7f0fad2c6cb8cba899fca588ee9d0c | swh:1:cnt:e66ac4b552876e2e4a3a9a7387cb607527302fbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=65-73/ | 489faa34e1b7f5f84574e22f753a3e2db9c77e05 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/converter/TimestampedRecordConverterWrapper.java | TimestampedRecordConverterWrapper::convertRecord(String outputSchema, TimestampedRecord<I> inputRecord, WorkUnitState workUnit) | function | @Override
public Iterable<TimestampedRecord<O>> convertRecord(String outputSchema, TimestampedRecord<I> inputRecord, WorkUnitState workUnit)
throws DataConversionException {
Iterable<O> convertedOutput = wrappedConverter.convertRecord(outputSchema, inputRecord.getPayload(), workUnit);
Op... |
1,996 | 441459f78151b08c5f83f41363f1745a | swh:1:cnt:e66ac4b552876e2e4a3a9a7387cb607527302fbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=60-63/ | 489faa34e1b7f5f84574e22f753a3e2db9c77e05 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/converter/TimestampedRecordConverterWrapper.java | TimestampedRecordConverterWrapper::convertSchema(String inputSchema, WorkUnitState workUnit) | function | @Override
public String convertSchema(String inputSchema, WorkUnitState workUnit) throws SchemaConversionException {
return inputSchema;
} |
1,997 | 22dacf30eb097e6db6acbeb54950526f | swh:1:cnt:80311b081738dd9a443e3632f9b0a9f8ba0af62e;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=39-143/ | 23b49efd88836d007ff29c1a61796c977bbe5d96 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/kafka/Kafka1TimestampedRecordExtractor.java | Kafka1TimestampedRecordExtractor | type | /**
* Extracts {@link TimestampedRecord} records from Kafka using Kafka1 client.
* The extracted record timestamp is set to the kafka record timestamp if the kafka
* record timestamp-type is in the list of extracted-timestamp-types defined using
* the property source.kafka.extract.timestampTypes (accepted values ar... |
1,998 | 2480595fbbba889a84ba2ca9d65658b4 | swh:1:cnt:80311b081738dd9a443e3632f9b0a9f8ba0af62e;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=91-100/ | 23b49efd88836d007ff29c1a61796c977bbe5d96 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/kafka/Kafka1TimestampedRecordExtractor.java | Kafka1TimestampedRecordExtractor::getUseCurrentTimestampAsDefault(WorkUnitState state) | function | /**
* Uses state CURRENT_TIMESTAMP_AS_DEFAULT_KEY property to define if record timestamp
* should be set to current-time if kafka timestamp can't be used (by opposition to be absent).
*
* @return The {@link TimestampType} list, empty if the property is not present.
*/
private boolean getUse... |
1,999 | ebb43b07920f379c65af9454394b1e49 | swh:1:cnt:80311b081738dd9a443e3632f9b0a9f8ba0af62e;origin=https://gitlab.wikimedia.org/repos/data-engineering/gobblin-wmf.git;lines=102-127/ | 23b49efd88836d007ff29c1a61796c977bbe5d96 | gobblin-wmf | analytics | gobblin-wmf-core/src/main/java/org/wikimedia/gobblin/kafka/Kafka1TimestampedRecordExtractor.java | Kafka1TimestampedRecordExtractor::decodeKafkaMessage(KafkaConsumerRecord message) | function | /**
* We need to override this protected method as the kafka timestamp information is not
* available in the {@link KafkaExtractor#decodeRecord(ByteArrayBasedKafkaRecord)} abstract method.
*/
@Override
protected TimestampedRecord<P> decodeKafkaMessage(KafkaConsumerRecord message) throws DataRecor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.