<commit_before>#!/usr/bin/env bash

set -x

download_schema()
{
    from=$1
    to=$2

    for run in {1..5}
    do
        curl -sf --compressed ${from} > ${to}
        result=$?
        if [ $result -eq 0 ]; then break; fi
        sleep 1
    done

    if [ $result -ne 0 ]; then exit $result; fi
}

# parent directory
basedir=$(dirname "$0")/..

FILES=( \
    "errors/error.json" \
    "errors/payload.json" \
    "sourcemaps/payload.json" \
    "transactions/mark.json" \
    "transactions/payload.json" \
    "transactions/span.json" \
    "transactions/transaction.json" \
    "context.json" \
    "process.json" \
    "request.json" \
    "service.json" \
    "stacktrace_frame.json" \
    "system.json" \
    "tags.json" \
    "user.json" \
)

mkdir -p ${basedir}/.schemacache/errors ${basedir}/.schemacache/transactions ${basedir}/.schemacache/sourcemaps

for i in "${FILES[@]}"; do
    download_schema https://raw.githubusercontent.com/elastic/apm-server/master/docs/spec/${i} ${basedir}/.schemacache/${i}
done
echo "Done."<commit_msg>(very) temporarily use 6.x branch of apm-server for json schema<commit_after>#!/usr/bin/env bash

set -x

download_schema()
{
    from=$1
    to=$2

    for run in {1..5}
    do
        curl -sf --compressed ${from} > ${to}
        result=$?
        if [ $result -eq 0 ]; then break; fi
        sleep 1
    done

    if [ $result -ne 0 ]; then exit $result; fi
}

# parent directory
basedir=$(dirname "$0")/..

FILES=( \
    "errors/error.json" \
    "errors/payload.json" \
    "sourcemaps/payload.json" \
    "transactions/mark.json" \
    "transactions/payload.json" \
    "transactions/span.json" \
    "transactions/transaction.json" \
    "context.json" \
    "process.json" \
    "request.json" \
    "service.json" \
    "stacktrace_frame.json" \
    "system.json" \
    "tags.json" \
    "user.json" \
)

mkdir -p ${basedir}/.schemacache/errors ${basedir}/.schemacache/transactions ${basedir}/.schemacache/sourcemaps

for i in "${FILES[@]}"; do
    download_schema https://raw.githubusercontent.com/elastic/apm-server/6.x/docs/spec/${i} ${basedir}/.schemacache/${i}
done
echo "Done."
{'fraction_non_alphanumeric': 0.17454375292466073, 'fraction_numerical': 0.008423022929340197, 'mean_word_length': 2.4764227642276424, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '395117', 'n_tokens_mistral': 783, 'n_tokens_neox': 763, 'n_words': 152}